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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
sgannon1
Frequent Visitor

'Token then expected' error

Hi all, 

 

Can anybody please tell me what 'token then expected' error means?

I have created the below formula (I am trying to allocated fiscal year to each month), but obviously I am doing something wrong.

 

 

 

Capture.PNG

1 ACCEPTED SOLUTION
Anonymous
Not applicable

You're using DAX syntax to write a function in M. The query editor uses a different language. It should be

 

=if [Month] > 9 then [Year] + 1 else [Year]

View solution in original post

4 REPLIES 4
kcantor
Community Champion
Community Champion

This is referring to the proper set up of the if statement. It is not like excel. It needs a 'then' and and 'else' instead of commas.

It should be:

=if [Month]>9 then [year] + 1 else [year]

If in PQL follws this format:

= if <Logical_test> then <result> else <alternate_result>





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

@kcantor  or @smpa01 See below If then error for custom column. It is only erroring out the first then- please advise how to fix this formula. thank you

If then Error.JPG

Anonymous
Not applicable

I figured it out nevermind. Once I removed all the ) before each of the thens the formula was accepted. Wish the error highlighted the ) parenthesis --calling it a token Then error is misleading bc the then is already there.

Anonymous
Not applicable

You're using DAX syntax to write a function in M. The query editor uses a different language. It should be

 

=if [Month] > 9 then [Year] + 1 else [Year]

Helpful resources

Announcements
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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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