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

Did you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now

Reply
jellis1971
Helper IV
Helper IV

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 want the custom column to show the number of the month.

So, please help me correct the syntax below, since it's not working:

IF [Month] =
"August" Then 8
ELSE IF "December" Then 12
ELSE IF "July" Then 7
ELSE IF "November" Then 11
ELSE IF "October" Then 10
ELSE IF "September" Then 9
ELSE IF "April" Then 4
ELSE IF "February" Then 2
ELSE IF "January" Then 1
ELSE IF "March" Then 3
ELSE IF "May" Then 5
ELSE IF "June" Then 6

Thanks!

John

1 ACCEPTED SOLUTION

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

View solution in original post

3 REPLIES 3
AntonioM
Solution Sage
Solution 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 

Thanks!  Does the beginning of the syntax start with [Month]?

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

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.