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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
phoenix
Creator
Creator

LOAD script - Assign field values to a variable

What is the easiest way to get to this without having to write several load steps and IF conditions for each code?

CODE_1_DATE is the date CODE_1 is placed, similarly for other codes

If an Account has two same codes, like 789 below, it has 120 in code_1 and code_2, I would need the 120 that is places latest. so it would be 1/9/2019

In the actual data I have as many as 12-15 codes.

HAVE:

ACCOUNTCODE_1CODE_2CODE_3code_4CODE_1_DATECODE_2_DATECODE_3_DATECODE_4_DATE
123120121122 1/2/20191/3/20191/4/2019 
4561201211221231/20/20191/3/20191/5/20191/8/2019
7891201201221211/8/20191/9/20191/10/20191/15/2019

 

WANT:

ACCOUNTCODE_120CODE_120_DATECODE_121CODE_121_DATECODE_122CODE_122_DATECODE_123CODE_123_DATE
123Y1/2/2019Y1/3/2019Y1/4/2019  
456Y1/20/2019Y1/3/2019Y1/5/2019Y1/8/2019
789Y1/9/2019Y1/15/2019Y1/10/2019  
1 Reply
marcus_sommer

I doubt that I would try to solve this and other tasks with your displayed data-structure else I would transform it with two joined crosstable-loads - means to load code and code-date separate and joining them together:

The-Crosstable-Load

After it I'm not sure that I would flag everything within the datamodel else I could imagine that you could fetch your needed values with firstsortedvalue() directly within the UI. If it should really happens within the script you might also use min/max/firstsortedvalue in separate loadings and just keeping them as associated tables or maybe re-joining them to the resident table.

An alternatively to the aggregation approach might be to use interrecord-functions within a sorted load to access and compare the previous loaded records:

Peek-or-Previous

- Marcus