Forum Discussion
Anonymous
4 years agoNot applicable
Power Query Editor Custom Column: If, Then Formula
Hi: I'm trying to create a custom column in Power Query Editor with an if, then formula based on a field called "Month". "Month" holds the name of the month such as "January", "February", etc. I w...
- 4 years ago
Sorry, no it doesn't. It'll be the same as you have, so
if [Month] = "August" then 8 else if [Month] = "December" then 12 else if [Month] = "July" then 7 else if [Month] = "November" then 11 else if [Month] = "October" then 10 else if [Month] = "September" then 9 else if [Month] = "April" then 4 else if [Month] = "February" then 2 else if [Month] = "January" then 1 else if [Month] = "March" then 3 else if [Month] = "May" then 5 else if [Month] = "June" then 6
AntonioM
4 years agoSolution Sage
In power query, "if", "else" and "then" all need to be lower case
Each time you have a new "if" you need a full condition to check, so each time you'll need to type '[Month] = ', so
[Month] = "December" then 12 else if [Month] = "July" then 7
Anonymous
4 years agoNot applicable
Thanks! Does the beginning of the syntax start with [Month]?
- AntonioM4 years agoSolution Sage
Sorry, no it doesn't. It'll be the same as you have, so
if [Month] = "August" then 8 else if [Month] = "December" then 12 else if [Month] = "July" then 7 else if [Month] = "November" then 11 else if [Month] = "October" then 10 else if [Month] = "September" then 9 else if [Month] = "April" then 4 else if [Month] = "February" then 2 else if [Month] = "January" then 1 else if [Month] = "March" then 3 else if [Month] = "May" then 5 else if [Month] = "June" then 6