Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi there,
I have a column which I created using the DAX function. I wanted to create the same column in the power query editor (and want to get rid of the column created using DAX).
However, I got the following error:
Could anyone help me in converting DAX code into M language?
Solved! Go to Solution.
Try the conditional column and assign your appropriate value. The below image is just an example.
If it helps, mark it as a solution
Kudos are nice too
Hi @Dunner2020
If the above posts help, please kindly mark it as a answer to help others find it more quickly. thanks!
If not, please kindly elaborate more.
Hi @Dunner2020- I am not sure if i got this right but are you trying in power Query Editor to convert MonthName to Numbers.
I added a new Column from Example and mapped the months, M Code generated itself was something on the lines:
= Table.AddColumn(#"Renamed Columns", "Custom", each if [Month Name] = "Jan" then 10 else if [Month Name] = "Feb" then 11 else if [Month Name] = "Mar" then 12 else if [Month Name] = "Apr" then 1 else if [Month Name] = "May" then 2 else if [Month Name] = "June" then 3 else if [Month Name] = "July" then 4 else if [Month Name] = "Aug" then 5 else if [Month Name] = "Sep" then 6 else if [Month Name] = "Oct" then 7 else if [Month Name] = "Nov" then 8 else if [Month Name] = "Dec" then 9 else null, type number)
and i then removed the MonthName column
Does this help?
@Dunner2020 , same thing as been done and explained nicely in this article -https://www.thebiccountant.com/2018/02/15/generic-switch-function-query-editor-in-power-bi-and-power...
Try the conditional column and assign your appropriate value. The below image is just an example.
If it helps, mark it as a solution
Kudos are nice too
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 63 | |
| 55 | |
| 42 | |
| 41 | |
| 23 |
| User | Count |
|---|---|
| 171 | |
| 136 | |
| 119 | |
| 79 | |
| 54 |