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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
BartVlek
Helper II
Helper II

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 6
amitchandak
Super User
Super 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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you !! And what does it look like when the name of the new column should be SUPDISCDEF?

@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]
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

I transformed your suggestion to the actual situation. The shop doesn't have a name, but a number as you can see.

When I then copy-paste it to PBI-desktop and run, I receive a syntaxis error. What can it be? Do I not need to add the name of the table?

 

LEVKORTDEF =
SWITCH (
    TRUE (),
    [LEVERANCIER] = "ALDIPRESS"
        && [FIL] = "1", 65.00,
    [LEVERANCIER] = "BETAPRESS"
        && [FIL] = "1", 60.00,
    [LEVKORTING]
)

Anonymous
Not applicable

Hi @BartVlek ,

Please try to update the formula of your measure as below to remove double quotation since shop is number type:

LEVKORTDEF =
SWITCH (
    TRUE (),
    [LEVERANCIER] = "ALDIPRESS"
        && [FIL] = 165.00,
    [LEVERANCIER] = "BETAPRESS"
        && [FIL] =160.00,
    [LEVKORTING]
)

If the above method didn't resolve your problem, please provide the screen shot of syntax error and related formula. Thank you.

Best Regards

Rena

Thank you !

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.