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

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
burton
Contributor
Contributor

Write input column to varying target columns depending on content

Hi, 

I have a rather inconvenient input structure that I need to process in my load script. The third input column holds data that I need to allocate to either one or another table column depending on the value present.

Input structure: 

Level1Level2Level3 OR Label
ABC
DES_123

 

Desired Outcome:

Level1Level2Level3Label
ABC 
DE S_123


Is there any way to dynamically select the target column? I
've tried something similar to

[@3] as If(LEFT([@3],1)='S', 'Level3', 'Label') --- However, this raises an error.

I'm aware I could simply write an if-clause for both columns to be filled or to be left blank. The problem is the real data is more complex and more nested than shown above. As such the data for an output column could come from a number of different columns. A dynamic column allocation would make my life a lot easier.

Any ideas on how to approach this? Thanks!

Labels (3)
1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Script Syntax does not allow fieldname to be specified conditionally.  I can think of two approaches:

1. Process your input file in multiple passes, processing each output field in a different pass. 

2. Generate a temporary three field Generic structure and then use Generic Load to put the data in the proper columns. See https://qlikviewcookbook.com/2010/05/use-cases-for-generic-load/

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com

View solution in original post

2 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Script Syntax does not allow fieldname to be specified conditionally.  I can think of two approaches:

1. Process your input file in multiple passes, processing each output field in a different pass. 

2. Generate a temporary three field Generic structure and then use Generic Load to put the data in the proper columns. See https://qlikviewcookbook.com/2010/05/use-cases-for-generic-load/

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com

burton
Contributor
Contributor
Author

Ok, I'll have to give that a go. Thanks for the quick reply!