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

Excluding ID's with IF and ApplyMap

Hi,

I would like some help with the following:

I'm working with a project that needs to separate certain ID's from a field. One ID (12345) was already separated before (by someone else), and now they want to exclude one more ID (34512). The code that was used to exclude the first ID is:

mapUniqueID:
MAPPING LOAD autonumber(%Key_FactoryOrder), [Unique ID]
FROM *****.qvd (QVD)
;

if(num(%Key_Dealer)=1 AND applymap('mapUniqueID',autonumber(%Key_FactoryOrder))='12345','12345',%Key_Dealer) AS [Retailer],

 

I've tried so many different options but with no luck. Is there a simple way to fix it? E.g.

if(num(%Key_Dealer)=1 AND applymap('mapUniqueID',autonumber(%Key_FactoryOrder))='12345','12345',%Key_Dealer,
if(num(%Key_Dealer)=1 AND applymap('mapUniqueID',autonumber(%Key_FactoryOrder))='34512','34515',%Key_Dealer)) AS [Retailer],


It should be quite easy but I've been sitting with it for a while now and I can't get it to work.

 

 

Sincerely
K

6 Replies
rubenmarin

The syntax if is: If(condition, TrueActions, FalseActions).

Nested different If's (the FalseActions is another If): If(condition, TrueActions, If(condition, TrueActions, FalseActions)).

So tou can try this:

if(num(%Key_Dealer)=1 AND applymap('mapUniqueID',autonumber(%Key_FactoryOrder))='12345'
  ,'12345'
  , if(num(%Key_Dealer)=1 AND applymap('mapUniqueID',autonumber(%Key_FactoryOrder))='34512'
    ,'34515'
    ,%Key_Dealer
  )
) AS [Retailer],

 

sunny_talwar

Might be easier to just do this

If(Num(%Key_Dealer) = 1 and Match(ApplyMap('mapUniqueID', AutoNumber(%Key_FactoryOrder)), '12345', '34515'),
  ApplyMap('mapUniqueID', AutoNumber(%Key_FactoryOrder)),
  %Key_Dealer
) AS [Retailer],
rubenmarin

I don't know why, but when I click the 'Like' button it seems that doesn't works.

sunny_talwar

Not sure why would that be... seems to be working okay for me. Does this happen only for this post or any post?

rubenmarin

Any post, I wasn't aware until now. I wonder how many likes has been lost

sunny_talwar

That is strange, may be @Brett_Bleess can help us figure this out.