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

Announcements
Now accepting applications for the Qlik Luminary and Partner Ambassador Programs: Apply by July 6!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

IF-ELSE or CASE

Hello,

I'm trying to do a preceding load, and it will change the original value to something else.

For example, i have a column of zone in a table, which i need to rename the zone, from AP > Asia, EU > Europe.

I know in vb we normally do CASE, or even IF-ELSE. but is there IF-ELSE in Qlikview?

i did a nested IF-ELSE like this...

if(Geographical_zone='AF', RefzoneCode='EUROPE', (IF(Geographical_zone='AS-PA', RefzoneCode='ASIE', (if(Geographical_zone='NA', RefzoneCode='AMERIQ', (if(Geographical_zone='LA', RefzoneCode='AMERSU', (if(Geographical_zone='ME', RefzoneCode='EUROPE', ( if(Geographical_zone='EU', RefzoneCode='EUROPE') ) ) ) ) ) )))))as RefzoneCode,

doesn't really work. If you have better idea, please share with me?

Thanks.

Labels (1)
2 Replies
Not applicable
Author

With QlikView, I try to avoid using these classical if-else statements. Instead, try using the incredible associative power built-in to QlikView.

For example, try adding the following line of code to your script:

LOAD * INLINE [

Geographical_zone, RefzoneCode

AF, EUROPE

AS-PA, ASIE

NA, AMERIQ

LA, AMERSU

ME, EUROPE

EU, EUROPE

];

Once you reload your script with the code above, every record that has a matching Geographical_zone value will now be associated with a corresponding RefzoneCode. No functions or special coding required.

I hope this helps ensure your success.

Best regards,

James



Not applicable
Author

Hi James,

Thanks for your suggestion, ideally, that's the better solution. But due to my db structure in QV, i can't do it that way.

I need this zone to intact with the original table. after that, i'll use the value of this field to create key like (year & - & Zone) as PriKey.

but, or there's a way to do the same with your ideal? i haven't figured it out yet.

By the way, the nested if statement is working by removing the column name in the [then] condition.