Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Replacing a "fieldname resulting" complex nested if with what?

Hi


Picture this load script:

Items:
Load
ItemNo,
Qty,
if(ItemType=1,Price1, if(ItemType=2,Price2,if(ItemType3=3,Price3))) as Price,
...


This will work, but if there would be 20 different pricefields, it would make a looong nested if, which I would like to avoid. Ok, it's silly example, but still...


This is what I would like to do instead:


map_Pricefield:
Mapping Load * inline
[PriceType, Fieldname
1,Price1
2,Price2
3,Price3
...
];


Items:
Load
ItemNo,
Qty,
ApplyMap('map_Pricefield',ItemType) as Price,
...

But it will most likely not work, since the ApplyMap function do not return a "field" (as far as I know), it returns a "value", so what I would get in my new "Price field", is only the text "Price1" etc, and not value of the the fieldname [Price1].

So my question is:
Is it possible to replace a complex nested if where the result of he nested if's are fieldname(s) and not values?


brg Robert Svebeck

1 Solution

Accepted Solutions
Not applicable
Author

Hi Robert,

try this.

C u,

Stefano.

View solution in original post

3 Replies
Not applicable
Author

Hi Robert,

try this.

C u,

Stefano.

Not applicable
Author

Excellent Stefano! Perfect - just what I requested! Thanks!

/Robert

Not applicable
Author

Hi Robert,

1 thing, i put this example without control.

Be careful with the order of field in the concat.

Pick function take field in that order.

Tell me if u have some dubt.

Stefano.