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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
aaquis
New Member

DAX dynamic sum between two dates, when the date slicer is one of the parameters

Hello,

 

I've been trying, unsuccessfully, to calculate a measure summing up values between two dates. The lower limit date is MIN(Calendar[Date]) while the upper limit should be a dynamic selection from a Date Slicer. 

 

The last two items I've tried are: 

MNQ EndBalance = CALCULATE(SUM(Quantities[Value]),DATESBETWEEN('Calendar'[Date],
MIN('Calendar'[Date]),CALCULATE(MIN(Calendar[Date]),ALLSELECTED(Calendar[Date]))))

MNQ EndBalance = CALCULATE(SUM(Quantities[Value]),DATESBETWEEN('Calendar'[Date],
MIN('Calendar'[Date]),SELECTEDVALUE(Calendar[Date]))).

 

Link to sample file here: BetweenDatesSampleFile 

 

Any suggestions would be highly appreciated.

 

Thank you.

1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@aaquis,

 

Try this measure:

 

MNQ EndBalance = 
VAR vStartDate =
    MINX ( ALL ( 'Calendar' ), 'Calendar'[Date] )
VAR vEndDate =
    MAXX ( ALLSELECTED ( 'Calendar' ), 'Calendar'[Date] )
VAR vResult =
    CALCULATE (
        SUM ( Quantities[Value] ),
        DATESBETWEEN ( 'Calendar'[Date], vStartDate, vEndDate )
    )
RETURN
    vResult




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

Proud to be a Super User!




View solution in original post

2 REPLIES 2
DataInsights
Super User
Super User

@aaquis,

 

Try this measure:

 

MNQ EndBalance = 
VAR vStartDate =
    MINX ( ALL ( 'Calendar' ), 'Calendar'[Date] )
VAR vEndDate =
    MAXX ( ALLSELECTED ( 'Calendar' ), 'Calendar'[Date] )
VAR vResult =
    CALCULATE (
        SUM ( Quantities[Value] ),
        DATESBETWEEN ( 'Calendar'[Date], vStartDate, vEndDate )
    )
RETURN
    vResult




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

Proud to be a Super User!




Perfect! Works as expected.

Thank you so much, @DataInsights

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Top Solution Authors