Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowJuly 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more
Hi,
I am trying to generate a calculated colomn for reporting purposes and after being pointed towards SWITCH rather than IF functions I am now getting the below error in a custom column?
Clearly there should never be a comma in that name?
Any help would be appreciated
Thanks
Solved! Go to Solution.
Hey @nickashwell ,
it looks like there are two things mixed.
You can add a calculated column in Power BI. There the language is DAX.
Or you can add a column in Power Query. There the language is M.
In your screenshot you add a new column in Power Query, so the language is M. But the SWITCH function is DAX, so it would only work in a calculated column in Power BI.
If you want to add a column in Power Query, you have to use the M language. Sadly M doesn't have a SWITCH function, so you would have to add it as if and else. Check the syntax here:
M Language Conditionals - PowerQuery M | Microsoft Docs
Or as an example for the syntax:
if [my Column] >= 10 and [other Column] <= 100
then "Category 1"
else if [my Column] >= 20 and [other Column] <= 200
then "Category 2"
else "Category 3"
Hey @nickashwell ,
it looks like there are two things mixed.
You can add a calculated column in Power BI. There the language is DAX.
Or you can add a column in Power Query. There the language is M.
In your screenshot you add a new column in Power Query, so the language is M. But the SWITCH function is DAX, so it would only work in a calculated column in Power BI.
If you want to add a column in Power Query, you have to use the M language. Sadly M doesn't have a SWITCH function, so you would have to add it as if and else. Check the syntax here:
M Language Conditionals - PowerQuery M | Microsoft Docs
Or as an example for the syntax:
if [my Column] >= 10 and [other Column] <= 100
then "Category 1"
else if [my Column] >= 20 and [other Column] <= 200
then "Category 2"
else "Category 3"
@nickashwell SWITCH is a DAX function, not a power query M function. Unfortunately, there is no case or switch statement in power query.
Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.
Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.
| User | Count |
|---|---|
| 29 | |
| 27 | |
| 25 | |
| 25 | |
| 18 |
| User | Count |
|---|---|
| 54 | |
| 49 | |
| 43 | |
| 36 | |
| 32 |