Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
sk88024
Creator
Creator

Make a list using two column names in QlikView

Hello,

Let's say I have two columns, C1 and C2. Both columns are numeric types.

Now I want to create a new column (say C3)  in such a way that when the values are coming from C1, the list should contain the column name C1 and when the values are coming from C2, the list should contain the column name C2. 

Any help will be really appreciated. Thanks in advance!

For example: See the below Inline data. 

Data:
LOAD * INLINE [
C1, C2
764, 9062
4361, 74
36512, 908573
, 49659
35622,
,
];

and the final result should be like this:

C1 C2 C3
     
  49659 C2
764 9062 C1, C2
4361 74 C1, C2
35622   C1
36512 908573 C1, C2
1 Solution

Accepted Solutions
MarcoWedel

QlikCommunity_Thread_t5_QlikView-App-Dev_Make-a-list-using-two-column-names-in-QlikView_m-p_1856935_Pic1.png

table1:
LOAD C1, 
     C2, 
     If(Len(Trim(C1)),'C1')&If(Len(Trim(C1)) and Len(Trim(C2)),',')&If(Len(Trim(C2)),'C2') as C3
FROM [https://community.qlik.com/t5/QlikView-App-Dev/Make-a-list-using-two-column-names-in-QlikView/m-p/1856935] (html, codepage is 1252, embedded labels, table is @1);

 

hope this helps

Marco

View solution in original post

3 Replies
Gysbert_Wassenaar

LOAD C1, C2, Alt(C1,C2) as C3 FROM ...source...


talk is cheap, supply exceeds demand
sk88024
Creator
Creator
Author

Thanks for your response. But this is not what I am looking for. I want the column names instead of values. I have tried to explain in a better way in my edited questions. Please response back if you think of a solution for it.

MarcoWedel

QlikCommunity_Thread_t5_QlikView-App-Dev_Make-a-list-using-two-column-names-in-QlikView_m-p_1856935_Pic1.png

table1:
LOAD C1, 
     C2, 
     If(Len(Trim(C1)),'C1')&If(Len(Trim(C1)) and Len(Trim(C2)),',')&If(Len(Trim(C2)),'C2') as C3
FROM [https://community.qlik.com/t5/QlikView-App-Dev/Make-a-list-using-two-column-names-in-QlikView/m-p/1856935] (html, codepage is 1252, embedded labels, table is @1);

 

hope this helps

Marco