Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

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 :

TypeValueRuleExpected Result
A10B + C +D +E250
B20C + D + E230
C50D + E180
D80E100
E100E100

 

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

  • 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])

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      both the columns are not incremental , column (Type) is a phase & it has to be in sequence . 

      • amitchandak's avatar
        amitchandak
        Icon for Super User rankSuper User

        Anonymous , Better to an index column in power query and try, the last formula. I shared a link for index column, if needed