I have a table with columns Date and Payer. Calculated column: rank =…
- User
I have a table with columns Date and Payer.
Calculated column: rank = RANKX(FILTER(Table1,Table1[Payer]=EARLIER(Table1[Payer])),‘Table1’[date],ASC)
Calculated measures: if = var _current = MAX(Table1[date]) var _next = CALCULATE ( MAX ( ‘Table1’[date] ), FILTER ( ALLEXCEPT(Table1, Table1[Payer]), ‘Table1’[rank] = MAX ( ‘Table1’[rank] ) + 1 ) ) var _datdiff = DATEDIFF ( _current, _next, DAY ) RETURN IF ( _datdiff = 1, 0, 1 )
accumulative = SUMX( FILTER( ALL(Table1), ‘Table1’[date]<=MAX(‘Table1’[date]) ), [if] )
Modify accumulative to SUM across different values of Payer.
The input is
Date Payer 2021-01-01 A 2021-01-03 A 2021-01-02 A 2021-01-05 A 2021-01-01 B 2021-01-02 B 2021-01-06 B 2021-01-10 B 2021-01-09 B 2021-01-11 B The expected output is
Date Payer rank if accumulative 2021-01-01 A 1 0 0 2021-01-03 A 3 1 2 2021-01-02 A 2 1 1 2021-01-05 A 4 0 2 2021-01-01 B 1 0 0 2021-01-02 B 2 1 1 2021-01-06 B 3 1 2 2021-01-10 B 5 0 3 2021-01-09 B 4 1 3 2021-01-11 B 6 1 4 - Assistant
To modify the "accumulative" calculated measure to sum across different values of Payer, you can use the following formula:
accumulative = SUMX ( FILTER ( ALL ( Table1 ), 'Table1'[date] <= MAX ( Table1[date] ) && 'Table1'[rank] <= MAX ( Table1[rank] ) ), [if] )
This formula includes an additional condition in the FILTER function to only consider rows where the rank is less than or equal to the maximum rank for the current Payer. By adding this condition, the SUMX function will calculate the sum correctly across different Payer values.
Using this modified formula, the expected output for the given input would be as follows:
Date Payer rank if accumulative 2021-01-01 A 1 0 0 2021-01-03 A 3 1 2 2021-01-02 A 2 1