COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: hespora on 18 May 2020 06:08:32 AM

Title: Concatenate as aggregation
Post by: hespora on 18 May 2020 06:08:32 AM
Situation: Relational DB, I have a simple query with 2 Dimensions and no facts. Dim1 is unique, whereas Dim2 can have the same value multiple times, e.g.:

Dim1   Dim2
A      X
B      X
C      X
D      Y
E      Y
F      Z


what I now need is a way to return a single query row per value for Dim2, with a concatenation of the relevant values for Dim1, e.g.:

Dim1   Dim2
A,B,C  X
D,E    Y
F      Z


I know how to do this *in layout* using repeaters, but this time, I need it in a query, as I need to join that query to another. Does anyone have any idea on how to achieve this?
Title: Re: Concatenate as aggregation
Post by: ashley on 18 May 2020 07:36:30 AM
I haven't test this in a list, but CognosPaul has an article on "listagg" which concatenates text together using a db2 function. It might be possible to user other db functions instead if you are not on db2?

http://cognospaul.com/2014/10/20/quickie-aggregating-text-cognos-crosstab/
Title: Re: Concatenate as aggregation
Post by: hespora on 20 May 2020 05:55:24 AM
Thank you very much; I'll have a look at that and fiddle around with it!