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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Lizzieleman
Frequent Visitor

M code help needed for Fiscal year column in format 23-24 not just 2023

Hi there, I had some help me get to this formula

 

I've made a date table in power query and I'm looking to add a fiscal year column in the format 2023-24

 

if (Date.Month([Date])) <=3 , number.ToText(Date.Year([Date])) & "-" & Text.End(Number.ToText(Date.Year([Date])+1),2)) , Number.ToText(Date.Year([Date])+1) & "-" & Text.End(Number.ToText(Date.Year([Date])+2),2))

 

However it gives me the error "Token 'then' expected", could someone help me figure this out?

1 ACCEPTED SOLUTION
HotChilli
Community Champion
Community Champion

I think you might be mixing up the DAX syntax with Power Query syntax on this.  To debug, simplify the code, use dummy values until you get it to work, then introduce the more complex code.

Start with this

if Date.Month([Date]) <=3 then "a" else "b"

View solution in original post

1 REPLY 1
HotChilli
Community Champion
Community Champion

I think you might be mixing up the DAX syntax with Power Query syntax on this.  To debug, simplify the code, use dummy values until you get it to work, then introduce the more complex code.

Start with this

if Date.Month([Date]) <=3 then "a" else "b"

Helpful resources

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

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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