COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: longbaobao on 31 Oct 2013 02:33:05 PM

Title: Aggregation funtion in Query
Post by: longbaobao on 31 Oct 2013 02:33:05 PM
How can I write an aggregation function for muti columns. For example, I want to get the maximum number of column [A] depends on column [D] and [C].

Is there a valid syntax to fulfill the task, like maximum([A] for ([D] and [C]))?   (This one is illegal)
Title: Re: Aggregation funtion in Query
Post by: blom0344 on 31 Oct 2013 03:39:54 PM
The max function is evaluated against other non-aggregates within the query automatically. If you want to apply a context (evaluate against a limited set of columns) then you use the for predicate.

for 2 columns:  maximum([A] for [col1],[col2])

In your example what is [C]  ?
Title: Re: Aggregation funtion in Query
Post by: longbaobao on 31 Oct 2013 04:28:42 PM
Quote from: blom0344 on 31 Oct 2013 03:39:54 PM
The max function is evaluated against other non-aggregates within the query automatically. If you want to apply a context (evaluate against a limited set of columns) then you use the for predicate.

for 2 columns:  maximum([A] for [col1],[col2])

In your example what is [C]  ?

Sorry, I was using [ B ] and this one was explained as BOLD... Thanks for your suggestion. I'll have a try