Forum Discussion
Conditional sum based on next row
Hi,
I have a requirement to calculate the total for the current row based on the next rows using DAX :
Data Set :
| Type | Value | Rule | Expected Result |
| A | 10 | B + C +D +E | 250 |
| B | 20 | C + D + E | 230 |
| C | 50 | D + E | 180 |
| D | 80 | E | 100 |
| E | 100 | E | 100 |
How I can solve this .
Thanks.
Anonymous , change like
new column = if( table[index] < max(table[Index]), sumx(filter(Table, [index] > earlier([index]) ) , [Value]) ,table[Index])
Sorry, I did not notice that
7 Replies
- amitchandakSuper User
Anonymous , if the type or value are incremental in nature try a new column like below. Or add an index column in power query and use that https://stackoverflow.com/questions/45715963/creating-an-index-column-for-power-bi
new column = sumx(filter(Table, [Type] > earlier([Type]) , [Value])
or
new column = sumx(filter(Table, [Value] > earlier([Value]) , [Value])
or
new column = sumx(filter(Table, [index] > earlier([index]) , [Value])
- AnonymousNot applicable
both the columns are not incremental , column (Type) is a phase & it has to be in sequence .
- amitchandakSuper User
Anonymous , Better to an index column in power query and try, the last formula. I shared a link for index column, if needed