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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Get the Amount before the selected start date in the slicer

Hi,

 

    I have a report where there will be a date slicer, I want to sumup the amount before the start date I have choosen in the date slicer.

 

    I'm using the below DAX to get the selected start date, 

    FromDate = CALCULATE ( MIN ( 'Document Date'[Date] ), ALLSELECTED ( 'Document Date'[Date] ) )

 

     Then, I'm using the below DAX to get the Amount before the start date. This is not working.

     PreviousDaySum = SUMX( FILTER( ALL(Finance),RELATED('Document Date'[Date])<[FromDate]),Finance[Local_Amount])

 

     When I hardcode the [FromDate] as below, it works
     HardCodedDetails = SUMX( FILTER( ALL(Finance),RELATED('Date'[Date] )<DATE(2020,02,01)),Finance[Amount])
 
is there any way to do that dynamically as per my selection in the slicer? You can download the sample file from here: https://1drv.ms/u/s!Am7aqNpyGxlugusCGZxJNEeEnebWgw?e=Qrhhv0
 
Regards,
Joe
1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

Hi, @Anonymous , as to your measure

 

PreviousDaySum =
SUMX (
    FILTER ( ALL ( Finance ), RELATED ( 'Document Date'[Date] ) < [FromDate] ),
    Finance[Local_Amount]
)

 

when the measure [FromDate] is referenced in another measure, the evaluation context already dramatically changed, i.e. row context from ALL( finance ) is transited to filter context to evaluate [FromDate].

A correction is straightforward enough,

 

PreviousDaySum =
VAR __before = [FromDate]
RETURN
    SUMX (
        FILTER ( ALL ( Finance ), RELATED ( 'Document Date'[Date] ) < __before ),
        Finance[Local_Amount]
    )

 

Yet I myselft prefer to choose "Before" type of slicer on the date column; it does the trick with a simplest measure

Total = SUM( Finance[Amount] )

Untitled.png

 


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

1 REPLY 1
CNENFRNL
Community Champion
Community Champion

Hi, @Anonymous , as to your measure

 

PreviousDaySum =
SUMX (
    FILTER ( ALL ( Finance ), RELATED ( 'Document Date'[Date] ) < [FromDate] ),
    Finance[Local_Amount]
)

 

when the measure [FromDate] is referenced in another measure, the evaluation context already dramatically changed, i.e. row context from ALL( finance ) is transited to filter context to evaluate [FromDate].

A correction is straightforward enough,

 

PreviousDaySum =
VAR __before = [FromDate]
RETURN
    SUMX (
        FILTER ( ALL ( Finance ), RELATED ( 'Document Date'[Date] ) < __before ),
        Finance[Local_Amount]
    )

 

Yet I myselft prefer to choose "Before" type of slicer on the date column; it does the trick with a simplest measure

Total = SUM( Finance[Amount] )

Untitled.png

 


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Helpful resources

Announcements
November Fabric Update Carousel

Fabric Monthly Update - November 2025

Check out the November 2025 Fabric update to learn about new features.

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!

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.

Users online (29)