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
Anonymous
Not applicable

Dax to return date range for Fiscal YTD based on today

I have a calendar table with fields Date, Year(Calendar), and Year(Fiscal). I need a measure that will return the date range logic as follows, but I can't figure out the proper syntax:

 

Dates between:  

   Min(Calendar[Date] where Year(Fiscal) = same Year(Fiscal) as today)    and

   Calendar[Date] = today()

 

So if the start of current FY = 4/1/21, the date range it would return is 4/1/2021 - 5/6/2021. Thoughts for as compact of dax as possible?

4 REPLIES 4
sayaliredij
Super User
Super User

Hi @Anonymous 

 

Sorry I missed fiscal year thingy

 

Could you try following formula

 

DatesYTD-Fiscal = 
var cur = Today()
VAR StartDate = DATE ( Year(cur), 4, 1 )
VAR EndDate = cur
RETURN
DATESBETWEEN ( 'Date'[Date], StartDate, EndDate )
ORDER BY [Date]

 

Regards,

Sayali





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

Proud to be a Super User!




Anonymous
Not applicable

I am unable to run because I can't get syntax right for how it fits into a measure, but just looking at it seems like it's not going to be right because it's looking at the year of today. So, theoretically it works when we're in the months where Calendar and Fiscal year numbers are the same, but January of next year is not going to work.

sayaliredij
Super User
Super User

Hi 

 

You can use the following DAX Formule. It will return the table with dates you are looking for

DatesYTD = 

CALCULATETABLE (
DATESYTD ( 'Date'[Date] ),
'Date'[Date] = TODAY ()
)

 Regards,

Sayali

 

If this post helps, then please consider Accept it as the solution to help others find it more quickly





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

Proud to be a Super User!




Anonymous
Not applicable

How does that fit in to checking that the date is based on the current Fiscal year?

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.