Forum Discussion
DPozo
2 years agoNew Member
Problems with EARLIER
Hi everyone,
I got a table like this:
| WEEK | BELL | REJECTED |
1 | 1 | 1 |
| 1 | 2 | 1 |
| 1 | 1 | 2 |
| 1 | 2 | 3 |
| 2 | 1 | 25 |
| 2 | 2 | 26 |
| 2 | 1 | 4 |
| 2 | 2 | 2 |
| 2 | 1 | 0 |
I would like to measure whats the maximum total value for every bell by week.
For example: in the previous table, if I select "WEEK 1", the measure must show 4 (3+1 > 1+2). For "WEEK 2", the measure must show 29 (25+4 > 26 + 2).
I have this DAX code:
Value =
CALCULATE (
SUM ( LEAKDETAILS[REJECTED] ),
LEAKDETAILS[BELL] = EARLIER(LEAKDETAILS[BELL]),
LEAKDETAILS[WEEK] = EARLIER(LEAKDETAILS[WEEK])
)
But I have an error in the EARLIER.
- Anonymous2 years ago
You can use a measure like this - taking the Top 1 descending
Top1 = SUMX(TOPN(1,SUMMARIZE(WeekBellRejected,WeekBellRejected[Bell],"TotalRejected", SUM(WeekBellRejected[Rejected])),[TotalRejected], DESC),[TotalRejected])
5 Replies
- AnonymousNot applicable
Use TOPN function with Top 1 - TOPN function (DAX) - DAX | Microsoft Learn
- DPozoNew Member
I don't understand your answer.
- AnonymousNot applicableTop1 = SUMX(TOPN(1,SUMMARIZE(WeekBellRejected,WeekBellRejected[Bell],"TotalRejected", SUM(WeekBellRejected[Rejected])),[TotalRejected], DESC),[TotalRejected])
- AnonymousNot applicable
You can use a measure like this - taking the Top 1 descending
Top1 = SUMX(TOPN(1,SUMMARIZE(WeekBellRejected,WeekBellRejected[Bell],"TotalRejected", SUM(WeekBellRejected[Rejected])),[TotalRejected], DESC),[TotalRejected])- DPozoNew MemberIt works perfectly! Thanks!