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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
baderbd
Contributor II
Contributor II

if expression looking at multiple dimensions

Hi,

I am trying to use an IF expression to look at a list of ship methods and if its on the list return 'Parcel' and if not 'Freight' when I use the expression below it always says 'Freight'.  I tried doing a "Match" but I could not get the expression to work.   What am I missing?

=if([Ship Method]='FEDEX-Air-International Priority''FEDEX-Air-International Priority Late Day''FEDEX-Air-Next Day Air Early AM''FEDEX-Air-Priority Field Engineer''FEDEX-Air-Priority Overnight''FEDEX-Air-Standard Overnight''FEDEX-AIRHAZ-Priority Overnight''FEDEX-AIRHAZ-Standard Overnight''FEDEX-GROUND-Standard','Package','Freight')

Labels (1)
2 Replies
datagrrl
Creator III
Creator III

Unless I do not know something new in Qlik, you need to create a nested if statement to use multiple values. 

Like in this post.

https://community.qlik.com/t5/New-to-Qlik-Analytics/Nested-IF-Statements/td-p/1022597

You can also use the Match expression instead, which is more efficient.

https://community.qlik.com/t5/QlikView-App-Dev/If-statements-for-multiple-values/td-p/659682

 

So, this should work:

if(match([Ship Method],'FEDEX-Air-International Priority','FEDEX-Air-International Priority Late Day','FEDEX-Air-Next Day Air Early AM','FEDEX-Air-Priority Field Engineer','FEDEX-Air-Priority Overnight','FEDEX-Air-Standard Overnight','FEDEX-AIRHAZ-Priority Overnight','FEDEX-AIRHAZ-Standard Overnight','FEDEX-GROUND-Standard'),'Freight','Parcel')

MatheusC
Specialist II
Specialist II

@baderbd 

Returning to using Match as mentioned. See it like this:
With the Match function, you will be able to list multiple values ​​that exist in the field in question, but they need to be separated by , and quotation marks ‘’ (‘as it is a textual value’). The syntax should look like this


if(Match([Ship Method],'FEDEX-Air-International Priority',
'FEDEX-Air-International Priority Late Day',
'FEDEX-Air-Next Day Air Early AM',
'FEDEX-Air-Priority Field Engineer',
'FEDEX-Air-Priority Overnight',
'FEDEX-Air-Standard Overnight',
'FEDEX-AIRHAZ-Priority Overnight',
'FEDEX-AIRHAZ-Standard Overnight',
'FEDEX-GROUND-Standard'),'Package','Freight')

https://help.qlik.com/en-US/sense/May2024/Subsystems/Hub/Content/Sense_Hub/Scripting/ConditionalFunc....

- Regards ,  Matheus

Did you find a solution to your question? Mark the solution as accepted and if you found it useful, press the like button!