COGNOiSe.com - The IBM Cognos Community

IBM Cognos Analytics Platform => Cognos Analytics => Reporting => Topic started by: peewan on 19 Mar 2021 11:34:00 AM

Title: Put value in multiple column to 1 column and multiple rows
Post by: peewan on 19 Mar 2021 11:34:00 AM
I have code values in 5 diffrence column, and I want to put them in one column (mutiple row with same ID).
How could I do this?

ID        Column1    column2  column3
A12B    Code1        Code2     Code3

turn to:
ID      Column
A12B  Code1
A12B  Code2
A12b  Code3
Title: Re: Put value in multiple column to 1 column and multiple rows
Post by: adam_mc on 19 Mar 2021 01:52:43 PM
A crude solution would be to create 5 queries and then union them together - I would only do this if the number of code columns is known to be fixed and will not change.
Also, this assumes that each of the code columns are the same data type.
Each query would have the ID and one of the code columns as follows:

Query1:
ID, C1

Query2:
ID, C2

etc..

Then, union the 5 queries together and the resulting query will have your required output.
You will need to determine based on your use case if you need union or union all functionality.

Hope this helps,
Adam.
Title: Re: Put value in multiple column to 1 column and multiple rows
Post by: peewan on 19 Mar 2021 05:31:02 PM
Thank you!