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

Announcements
Talend Cloud AWS EU Scheduled Outage: Starting Tues 26 May 21:00 CEST with expected completion Wed 27 May 01:00 CEST
cancel
Showing results for 
Search instead for 
Did you mean: 
sridhar_sigired
Creator
Creator

Alternate to Nested if condition

Hi,

I have nested if condition something like below (too nested).

IF (A like 'AZK*' , 'Azzar',

IF (A like 'VDN*' , 'Vodapone',

IF (A like 'WB*' , 'WorldBlue',

IF (A like 'wow*' , 'WOW! Security',

IF (A like 'ZA*' , 'ZoneAlarm',

IF (A like 'ys*' , 'sdgrsw',

'Unknown')))))

Can i use Match or any other function to avoid this nested IF??? for better performance?

Regards,

Sridhar

Labels (1)
1 Solution

Accepted Solutions
tresB
Champion III
Champion III

Pick(WildMatch(A ,'AZK*' , 'VDN*','WB*','wow*','ZA*', 'ys*')+1, 'Unknown', 'Azzar', 'Vodapone','WorldBlue','WOW! Security', 'ZoneAlarm','sdgrsw')

View solution in original post

7 Replies
sunny_talwar
MVP
MVP

Try this:

Pick(WildMatch(A, 'AZK*', 'VDN*', 'WB*', 'wow*', 'ZA*', 'ys*', A), 'Azzar', 'Vodapone', 'WorldBlue', 'WOW! Security', 'ZoneAlarm', 'sdgrsw', 'Unknown')

tresB
Champion III
Champion III

Pick(WildMatch(A ,'AZK*' , 'VDN*','WB*','wow*','ZA*', 'ys*')+1, 'Unknown', 'Azzar', 'Vodapone','WorldBlue','WOW! Security', 'ZoneAlarm','sdgrsw')

sridhar_sigired
Creator
Creator
Author

May i know why we have used +1 here?

tresB
Champion III
Champion III

If there would be no match, wildmatch() would return 0, otherwise it's match index . By adding 1 to 0, pick() is told to pick the 1st text, i.e- 'Unknown'. For rest of the matched values, position is deferred by 1. Hope this helps.

sridhar_sigired
Creator
Creator
Author

Hi Sunny,

Unknown used here as for if not else, not to replace as 'A'. Can you clear the confusion?

sunny_talwar
MVP
MVP

In the new field that will be created you want it to be called 'Unknown', if it doesn't match any other names that we listed within WildMatch()?

sridhar_sigired
Creator
Creator
Author

OK Let me try yours and from tresesco. And take the one which is working. Thank you.