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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
KasRotodyne
Frequent Visitor

Switch Formula

I have been trying to use the Switch Formula in Power BI. Without much luck... Can someone look at it and tell me what I am doing wrong
 
B_Inkoopbestemming =
Switch(
'T_Inkoop Data& Financieel'[B_RequirementType]=1, "Verkoop",
'T_Inkoop Data& Financieel'[B_RequirementType]=2, "Productie",
'T_Inkoop Data& Financieel'[B_RequirementType]=3, "Voorraad",
'T_Inkoop Data& Financieel'[B_RequirementType]=4, "Kosten",
'T_Inkoop Data& Financieel'[B_RequirementType]=5, "Ongepland"
)
2 ACCEPTED SOLUTIONS
tamerj1
Community Champion
Community Champion

Hi @KasRotodyne 

please try

B_Inkoopbestemming =
SWITCH (
    TRUE (),
    'T_Inkoop Data& Financieel'[B_RequirementType] = 1, "Verkoop",
    'T_Inkoop Data& Financieel'[B_RequirementType] = 2, "Productie",
    'T_Inkoop Data& Financieel'[B_RequirementType] = 3, "Voorraad",
    'T_Inkoop Data& Financieel'[B_RequirementType] = 4, "Kosten",
    'T_Inkoop Data& Financieel'[B_RequirementType] = 5, "Ongepland"
)

View solution in original post

@KasRotodyne 

I cannot read this language but I may guess. Please try

B_Inkoopbestemming =
SWITCH (
    TRUE (),
    'T_Inkoop Data& Financieel'[B_RequirementType] = "1", "Verkoop",
    'T_Inkoop Data& Financieel'[B_RequirementType] = "2", "Productie",
    'T_Inkoop Data& Financieel'[B_RequirementType] = "3", "Voorraad",
    'T_Inkoop Data& Financieel'[B_RequirementType] = "4", "Kosten",
    'T_Inkoop Data& Financieel'[B_RequirementType] = "5", "Ongepland"
)

View solution in original post

4 REPLIES 4
tamerj1
Community Champion
Community Champion

Hi @KasRotodyne 

please try

B_Inkoopbestemming =
SWITCH (
    TRUE (),
    'T_Inkoop Data& Financieel'[B_RequirementType] = 1, "Verkoop",
    'T_Inkoop Data& Financieel'[B_RequirementType] = 2, "Productie",
    'T_Inkoop Data& Financieel'[B_RequirementType] = 3, "Voorraad",
    'T_Inkoop Data& Financieel'[B_RequirementType] = 4, "Kosten",
    'T_Inkoop Data& Financieel'[B_RequirementType] = 5, "Ongepland"
)

KasRotodyne_0-1656944962345.pngKasRotodyne_1-1656945005086.png

@tamerj1 

@selimovd 

 

 

Thanks for replying, but both formulas return the same error, how do I incorporate the VALUE or FORMAT function?

@KasRotodyne 

I cannot read this language but I may guess. Please try

B_Inkoopbestemming =
SWITCH (
    TRUE (),
    'T_Inkoop Data& Financieel'[B_RequirementType] = "1", "Verkoop",
    'T_Inkoop Data& Financieel'[B_RequirementType] = "2", "Productie",
    'T_Inkoop Data& Financieel'[B_RequirementType] = "3", "Voorraad",
    'T_Inkoop Data& Financieel'[B_RequirementType] = "4", "Kosten",
    'T_Inkoop Data& Financieel'[B_RequirementType] = "5", "Ongepland"
)
selimovd
Most Valuable Professional
Most Valuable Professional

Hey @KasRotodyne ,

 

you missed the first argument. This is what you want to compare against the values. In your case the value of the column. 

This approach should work:

 

B_Inkoopbestemming =
SWITCH (
    'T_Inkoop Data& Financieel'[B_RequirementType],
    1, "Verkoop",
    2, "Productie",
    3, "Voorraad",
    4, "Kosten",
    5, "Ongepland"
)

 

 

You could also use a SWITCH with the TRUE as value to compare with. But that usually makes only sense if you want to compare different columns. For example if Country = "France", then return 100, if user = "Kas" then return 200.

The approach with SWITCH and TRUE would be like that, but as I said it wouldn't make sense here:

B_Inkoopbestemming =
SWITCH (
    TRUE (),
    'T_Inkoop Data& Financieel'[B_RequirementType] = 1, "Verkoop",
    'T_Inkoop Data& Financieel'[B_RequirementType] = 2, "Productie",
    'T_Inkoop Data& Financieel'[B_RequirementType] = 3, "Voorraad",
    'T_Inkoop Data& Financieel'[B_RequirementType] = 4, "Kosten",
    'T_Inkoop Data& Financieel'[B_RequirementType] = 5, "Ongepland"
)

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍

Best regards
Denis

Blog: WhatTheFact.bi
Follow me: twitter.com/DenSelimovic
 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.