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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Disaster110
Helper I
Helper I

Dynamic format string to return last fiscal QTR based on todays date

Hi All,
I am trying to automate a report heading with a dynamic format text string so the the formula returns this - 

Q1 2023-24

 

June - September 2023
For the previous fiscal quarter based on todays date. I have tried a few DAX formula like this - 

PreviousQuarterText =
VAR CurrentDate = TODAY()
VAR PreviousQuarterStart = STARTOFQUARTER(DATEADD(CurrentDate, -1, QUARTER))
VAR PreviousQuarterEnd = ENDOFQUARTER(DATEADD(CurrentDate, -1, QUARTER))
VAR PreviousYear = YEAR(CurrentDate) - 1

RETURN
"Q" & FORMAT(QUARTER(PreviousQuarterStart), "0") & " " &
FORMAT(PreviousYear, "0000") & "-" & FORMAT(PreviousYear + 1, "0000") & UNICHAR(10) & UNICHAR(10) &
FORMAT(PreviousQuarterStart, "MMMM") & " - " & FORMAT(PreviousQuarterEnd, "MMMM YYYY")

But this does not recognize the 'CurrentDate' or 'PreviousYear' parameters.
Would anyone have any suggestions please? (PS. I have a Fiscal year calendar table if that helps)

3 REPLIES 3
amitchandak
Super User
Super User

@Disaster110 , Try these formula

 


This Qtr Today =
var _today = today()
var _max = eomonth(_today, if( mod(Month(_today),3) =0,0,3-mod(Month(_today),3)))
var _min = eomonth(_max,-3)+1
return
CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

Last Qtr Today =
var _today = today()
var _max = eomonth(_today, -1*if( mod(Month(_today),3) =0,3,mod(Month(_today),3)))
var _min = eomonth(_max,-3)+1
return
CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

Same Qtr Last Year Today =
var _today = today()
var _max = eomonth(eomonth(_today, if( mod(Month(_today),3) =0,0,3-mod(Month(_today),3))),-12)
var _min = eomonth(_max,-3)+1
return
CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thankyou @amitchandak
This looks like it should work, and I will only use the "Last Qtr today" section.
However, Power BI does not recognise the [Net] function.  Could you explain or correct this part please?

@Disaster110 , Net is my own measure.

You can use your measure or sum(Table[Value])

 

refer

https://medium.com/chandakamit/cheat-sheet-power-bi-time-intelligence-formulas-using-today-654f26e27...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors