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 September 15. Request your voucher.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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