Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
CemK
Partner - Contributor
Partner - Contributor

Iterate through columns

Hey! 

I have the following poblem. My table looks like this:

Name1 Name2 
 Value1A Value2A
 Value1B Value2B

 

But I want my table to look like this: 

Name1Name2
Value1AValue2A
Value1BValue2B

 

Obviously, I could manually change the names of the columns in the script with the "as" command. Instead, I am looking for an algorithm that transforms my table automatically. 

As far as I know and researched, there aren't many Qlik functions for working with columns. Therefore i tried to accomplish something by working with variables, but the outcome was rather poor. My thoughts were:

1. Iterate through every column and give predefined variables a value (for example 0 if the column has only one non-zero value and 1 if the column has more than one value)

2. Take the first column whose variable has the value 0. Scan this column for its only non-zero value (for example Name1) and save it in another variable.

3. Take the first column whose variable has the value 1. Name this column with the variable from step 2

4. Do all this until there are no columns left

 

Maybe you (the community) could help me out here! 

 

Thanks in advance

Cem

Labels (2)
3 Replies
edwin
Master II
Master II

when you say your table looks like this

 

I have the following poblem. My table looks like this:

Name1 Name2 
 Value1A Value2A
 Value1B Value2B

 

is it an input file?  couldnt be a qlikview table as a QV table will always have a field name.  is it from EXCEL?  what is your source?  will the data always be one column to the right of the field name?  will there only always be just 2 columns or are the number of columns changing with the input file?

pls provide more info

CemK
Partner - Contributor
Partner - Contributor
Author

Hey Edwin, thanks for the reply!

The source is a csv file and the data will always be to the right of the field name. The number of columns in total is 34 and the number will not change.

tm_burgers
Creator III
Creator III

LOAD
Name1&F2 as Name1,
Name2&F4 as Name2

etc...