Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Gautam
Contributor
Contributor

Multiple IF replace and Alternate Function Needed

Hi All,

I have around 50 if Conditions on the same Field like salesman 1  = 'XXX' then name = ÝYYY',  like below I have to check for 50 values while loading the data. is there any alternate way to replace IF with another function?

LOAD * ,
if([Salesman 1]='MKAHN','Outside',

if([Salesman 1]='TZERB','Outside',

if([Salesman 1]='KNIBL','Outside',

if([Salesman 1]='ERAMO','Outside',

if([Salesman 1]='MNOBL','Outside',Salesmantype_old ))))) as Salesmantype;

1 Solution

Accepted Solutions
sunny_talwar

I would suggest to use ApplyMap() function with Mapping Load

View solution in original post

6 Replies
Anil_Babu_Samineni

We can do many ways?

1) Like what you done

2) Replace function with every time - Not recommended

3) Pick Match as follows - Recommended

Pick(Match([Salesman 1], 'MKAHN', 'TZERB', 'KNIBL', 'ERAMO', 'MNOBL'), 'Outside',Salesmantype_old) as Salesmantype

4) Mapping Table for all 50 rows with same name - Recommended

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
sunny_talwar

I would suggest to use ApplyMap() function with Mapping Load

kushalthakral
Creator III
Creator III

Hi
Pick function will not work the way you have specified needs to be write Outside many times

Thanks
Kushal
Anil_Babu_Samineni

@kushalthakral  Try and let us know where it is not working 🙂

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
sunny_talwar

@Anil_Babu_Samineni I think what @kushalthakral  is trying to say is that you need if instead of Pick to do this

If(Match([Salesman 1], 'MKAHN', 'TZERB', 'KNIBL', 'ERAMO', 'MNOBL'), 'Outside', Salesmantype_old) as Salesmantype

or you need this

Pick(Match([Salesman 1], 'MKAHN', 'TZERB', 'KNIBL', 'ERAMO', 'MNOBL') + 1, Salesmantype_old, 'Outside', 'Outside', 'Outside', 'Outside', 'Outside') as Salesmantype

Pick will need n+1 number of arguments for n number of arguments in Match.

Anil_Babu_Samineni

I agree with you @sunny_talwar  and @kushalthakral 

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful