The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
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])
Solved! Go to Solution.
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] )
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! |
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] )
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! |
User | Count |
---|---|
15 | |
12 | |
8 | |
7 | |
7 |
User | Count |
---|---|
24 | |
21 | |
12 | |
10 | |
7 |