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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Super User
Super User

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
Super User
Super User

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.