Forum Discussion
IF or SWITCH multiple values not getting syntax right
Hi I am struggling with this:
I need a new column in my model where I have the correct suppliers discount. There is a column SUPDISC but there are exceptions. So there are two columns that have an effect on SUPDISC: 1= SUPPLIER 2 = SHOP. Now what I want is something like:
if supplier = COCACOLA and SHOP = AMSTERDAM then the discount should be 65.00,
if supplier = PEPSICOLA and SHOP = ROTTERDAM then the discount should be 60,00,
in all the other occasions the value from SUPDISC must be applied.
Hope somebody can help me. Many thanks in advance
6 Replies
- amitchandakSuper User
BartVlek , a New column like
Switch ( true(),
[supplier] = "COCACOLA" && [SHOP] = "AMSTERDAM" , 65.00,
[supplier] = "PEPSICOLA" && [SHOP] = "ROTTERDAM" , 60.00,
[SUPDISC]
)Same can be done with IF
- BartVlekHelper II
Thank you !! And what does it look like when the name of the new column should be SUPDISCDEF?
- amitchandakSuper User
BartVlek , not sure what you mean by that. A new column like
SUPDISCDEF =
Switch ( true(),
[supplier] = "COCACOLA" && [SHOP] = "AMSTERDAM" , 65.00,
[supplier] = "PEPSICOLA" && [SHOP] = "ROTTERDAM" , 60.00,
[SUPDISC]
)