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! Request now

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
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