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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Dynamic Dates Between

Hello PowerBi Community, 

 

I'm building a report where I need a type of dynamic DATESBETWEEN,

The report is built from two different sources : 1 and 2, I'm looking for a way to compare data from source 1 at a specific date with data from source 2 at the same date (without creating a date table if possible),

 

This is an accounting report, so dates are related to the fiscal year : starting 1st July each year, and to a closing date (every month);

 

So the dates I would be needing would be : starting date 1st July of the current fiscal year, ending date last day of previous month

 

This is the calculate I came up with for now, but it doesn't seem to be working well for the ending date, and I wasn't able to make a dynamic formula for the starting date either :

JadeC_0-1648625514866.png

What would be the best way to make a dynamic datesbetween ?

 

Thank you very much,

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , why don't you use datesytd

 

example

 

YTD QTY forced=
var _max = eomonth(today(),-1)
return
if(max('Date'[Date])<=_max, calculate(Sum('order'[Qty]),DATESYTD('Date'[Date], "6/30")), blank())
//or
//calculate(Sum('order'[Qty]),DATESYTD('Date'[Date], "6/30"),filter('Date','Date'[Date]<=_max))
//calculate(TOTALYTD(Sum('order'[Qty]),'Date'[Date], "6/30"),filter('Date','Date'[Date]<=_max))

 

 

comments show alternate option. year end at 6/30

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

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , why don't you use datesytd

 

example

 

YTD QTY forced=
var _max = eomonth(today(),-1)
return
if(max('Date'[Date])<=_max, calculate(Sum('order'[Qty]),DATESYTD('Date'[Date], "6/30")), blank())
//or
//calculate(Sum('order'[Qty]),DATESYTD('Date'[Date], "6/30"),filter('Date','Date'[Date]<=_max))
//calculate(TOTALYTD(Sum('order'[Qty]),'Date'[Date], "6/30"),filter('Date','Date'[Date]<=_max))

 

 

comments show alternate option. year end at 6/30

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

Thank you very much ! It worked !

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.