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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Marshmallow
Helper II
Helper II

Adding more syntax to the M Query

Hi, 

I found the following syntax which is working for me: 

let a=#date(Date.Year([Date_Min_Signed]),7,1),
b=#date(Date.Year([Date_Min_Signed])+1,6,30)
in if [Date_Min_Signed]>=a and [Date_Min_Signed]<=b then "FY"&Text.End(Number.ToText(Date.Year([Date_Min_Signed])),2) else "FY"&Text.End(Number.ToText(Date.Year([Date_Min_Signed])-1),2)

 

Using this formula, the output is:

DateFinancial Year
4/7/2023FY23
6/3/2023FY22

 

However I would like the output to be: 

DateFinancial Year
4/7/2023FY23-24
6/3/2023FY22-23

 

Can someone please help?

2 ACCEPTED SOLUTIONS
MasonMA
Super User
Super User

@Marshmallow 

 

Hi, you simply need to append the second year in the format YY, which is always one year after the base year. With adjusted M codes below: 

 

let
    a = #date(Date.Year([Date_Min_Signed]), 7, 1),
    b = #date(Date.Year([Date_Min_Signed]) + 1, 6, 30),
    fyStartYear = if [Date_Min_Signed] >= a and [Date_Min_Signed] <= b then Date.Year([Date_Min_Signed]) else Date.Year([Date_Min_Signed]) - 1,
    fyEndYear = fyStartYear + 1,
    result = "FY" & Text.End(Text.From(fyStartYear), 2) & "-" & Text.End(Text.From(fyEndYear), 2)
in
    result

MasonMA_0-1752416778449.png

 

View solution in original post

grazitti_sapna
Super User
Super User

Hi @Marshmallow 

 

Please try the below M code:

let
a = #date(Date.Year([Date_Min_Signed]), 7, 1),
b = #date(Date.Year([Date_Min_Signed]) + 1, 6, 30),
fyStartYear = if [Date_Min_Signed] >= a and [Date_Min_Signed] <= b then Date.Year([Date_Min_Signed]) else Date.Year([Date_Min_Signed]) - 1,
fyEndYear = fyStartYear + 1,
result = "FY" & Text.End(Text.From(fyStartYear), 2) & "-" & Text.End(Text.From(fyEndYear), 2)
in
result


 I hope this solution helps you unlock your Power BI potential! If you found it helpful, click 'Mark as Solution' to guide others toward the answers they need.
 Love the effort? Drop the kudos! Your appreciation fuels community spirit and innovation.
 As a proud SuperUser and Microsoft Partner, we’re here to empower your data journey and the Power BI Community at large.
 Curious to explore more? [Discover here].
Let’s keep building smarter solutions together!


View solution in original post

7 REPLIES 7
grazitti_sapna
Super User
Super User

Hi @Marshmallow 

 

Please try the below M code:

let
a = #date(Date.Year([Date_Min_Signed]), 7, 1),
b = #date(Date.Year([Date_Min_Signed]) + 1, 6, 30),
fyStartYear = if [Date_Min_Signed] >= a and [Date_Min_Signed] <= b then Date.Year([Date_Min_Signed]) else Date.Year([Date_Min_Signed]) - 1,
fyEndYear = fyStartYear + 1,
result = "FY" & Text.End(Text.From(fyStartYear), 2) & "-" & Text.End(Text.From(fyEndYear), 2)
in
result


 I hope this solution helps you unlock your Power BI potential! If you found it helpful, click 'Mark as Solution' to guide others toward the answers they need.
 Love the effort? Drop the kudos! Your appreciation fuels community spirit and innovation.
 As a proud SuperUser and Microsoft Partner, we’re here to empower your data journey and the Power BI Community at large.
 Curious to explore more? [Discover here].
Let’s keep building smarter solutions together!


v-sgandrathi
Community Support
Community Support

Hi @Marshmallow,

Thank you for being a part of the Microsoft Fabric Community.

 

@MasonMA Thank you for providing the answer along with screenshots of the output.

If the response provided by the community member addressed your query, could you please confirm? It helps us ensure that the solutions provided are effective and beneficial for everyone.

Thank you.

Hi @Marshmallow,

 

Just checking in -- have you had a chance to review and try the provided solution? Kindly share the status whenever you get a chance.

 

Looking forward to your response
Thank you.

Ashish_Mathur
Super User
Super User

Hi,

Just in case you prefer a DAX solution, write this calculated column formula in the Calendar table

FY = if(month(Calendar[date])>=7,"FY"&right(year(calendar[date]),2)&"-"&right(year(calendar[date])+1,2),"FY"&right(year(calendar[date])-1,2)&"-"&right(year(calendar[date]),2))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Ashish_Mathur
Super User
Super User

Hi,

Just in case you prefer a DAX solution, write this calculated column formula in the Calendar table

FY = if(month(Calendar[date])>=7,"FY"&right(year(calendar[date]),2)&"-"&right(year(calendar[date])+1,2),"FY"&right(year(calendar[date])-1,2)&"-"&right(year(calendar[date]),2))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
MasonMA
Super User
Super User

@Marshmallow 

 

Hi, you simply need to append the second year in the format YY, which is always one year after the base year. With adjusted M codes below: 

 

let
    a = #date(Date.Year([Date_Min_Signed]), 7, 1),
    b = #date(Date.Year([Date_Min_Signed]) + 1, 6, 30),
    fyStartYear = if [Date_Min_Signed] >= a and [Date_Min_Signed] <= b then Date.Year([Date_Min_Signed]) else Date.Year([Date_Min_Signed]) - 1,
    fyEndYear = fyStartYear + 1,
    result = "FY" & Text.End(Text.From(fyStartYear), 2) & "-" & Text.End(Text.From(fyEndYear), 2)
in
    result

MasonMA_0-1752416778449.png

 

FBergamaschi
Super User
Super User

This is a Power Query question, please post it in the right forum

 

https://community.fabric.microsoft.com/t5/Power-Query/bd-p/power-bi-services

 

If this helped, please consider giving kudos and mark as a solution

@me in replies or I'll lose your thread

consider voting this Power BI idea

Francesco Bergamaschi

MBA, M.Eng, M.Econ, Professor of BI

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

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

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.

Top Solution Authors