Qlik Community

App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
IMPORTANT security patches for GeoAnalytics Server available to download: READ DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
luiluigi
Contributor II
Contributor II

Simplifying Loads...

Hi Community.

I read a unique key from a resident temp table. I need to store it in a result table and I need to add to each key two different constants into the same field. This will obviously doubled the number of records in the result table.

Now I proceed like this...

Result:

Load

     Key,

     'N' as Const

Resident Temp;

Load

     Key,

     'V' as Const

Resident Temp;

It is no racket science and I can live with that, but I'm convinced that the result can be achieved with one simple load.

Please advice...

TL

1 Solution

Accepted Solutions
pabloviera
Creator
Creator

Hi,

I think this should work

for n=1 to 2

Result:

load

  Key,

  if($(n)=1, 'N' ,'V') as Const

resident Temp;

next n;

Not sure if it's that much cleaner or faster to be honest

View solution in original post

3 Replies
pabloviera
Creator
Creator

Hi,

I think this should work

for n=1 to 2

Result:

load

  Key,

  if($(n)=1, 'N' ,'V') as Const

resident Temp;

next n;

Not sure if it's that much cleaner or faster to be honest

luiluigi
Contributor II
Contributor II
Author

Hi Pablo.

Thank you for your idea. Yes, it works and it gives correct output.

BUT...

Let's assume, that we have more then 2 constants to add to the key. And moreover, the number of constants can change dynamically...

Is there any other technique how to get desired outcome without using For-Next structure?

Please advice...

TL

pabloviera
Creator
Creator

Hello,

we'd need to know how are the constants stored and the logic behind assigning them to each key before coming up with a technique to apply.

Take into account you can't have 2 different expressións for the same field in the same load, so If you want to code the LOAD only once,  it will have to be inside some sort of loop or use a concatenated field with concat(), concatenated ApplyMap(),  etc.

Regards