Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
I followed a formula found on this forum, confirmed as the solution to changing a column of month names to date format in a new column and Power Query is rejecting the use of SWITCH. Why is this a confirmed answer if PQ doesn't recognise the function?
This is what I have, copied almost verbatum (Col names changed is all):
= Table.AddColumn(#"Changed Type4", "Month Num", each SWITCH([Month],
"January", Format (Date(2020,1,1), m),
"February", Format (Date(2020,2,1), m),
"March", Format (Date(2020,3,1), m),
"April", Format (Date(2020,4,1), m),
"May", Format (Date(2020,5,1), m),
"June", Format (Date(2020,6,1), m),
"July", Format (Date(2020,7,1), m),
"August", Format (Date(2020,8,1), m),
"September", Format (Date(2020,9,1), m),
"October", Format (Date(2020,10,1), m),
"November", Format (Date(2020,11,1), m),
"December", Format (Date(2020,12,1), m)
))
I need ot make a cumulative sum column by month (ie, Total for January, then total for Jan and Feb, so on). All I have is the month name in the source data. If anyone know what I'm doing wrong please help.
Solved! Go to Solution.
Hi @LYorkToenniges,
That solutions appears to be a calculated column (DAX) not a custom column (Power Query). To get the month number from a month name, enter this in to the formula area of the Add Custom Column dialog box:
Date.Month( Date.From( [Month] & "- 2020"))
Based on your example I assumed your month name field is called: [Month] by appending a year, the string can be converted into a date value from which a month number can be obtained.
I hope this is helpful
@LYorkToenniges @m_dekorte is absolutely correct. SWITCH is a DAX function, there is no native switch or case function in Power Query. Please reply with a link to the forum post you found so that I can unmark the post as the solution because it is clearly not correct.
This was the reference I was using:
https://community.fabric.microsoft.com/t5/Desktop/Converting-month-name-to-date/td-p/2938608
Maybe I'm misunderstanding how they are creating the calculated column. It seems the only way is in power query, am I missing a way to make columns with dax formulas? I've only used it to create measures.
Hi @LYorkToenniges,
That solutions appears to be a calculated column (DAX) not a custom column (Power Query). To get the month number from a month name, enter this in to the formula area of the Add Custom Column dialog box:
Date.Month( Date.From( [Month] & "- 2020"))
Based on your example I assumed your month name field is called: [Month] by appending a year, the string can be converted into a date value from which a month number can be obtained.
I hope this is helpful
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 3 | |
| 3 | |
| 2 |
| User | Count |
|---|---|
| 8 | |
| 6 | |
| 6 | |
| 6 | |
| 5 |