Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Recursive column in DAX

Hey, How can I achieve the following in a column in a DAX, this sounds a bit like recursive.  I have  a table like following in PowerBI, in which I wish to populate Column B in the following step...
  • v-frfei-msft's avatar
    7 years ago

    Hi Anonymous ,

     

    To create two calculated column as below.

     

    Column = 
    VAR k =
        FILTER ( 'Table', 'Table'[Column A] <> BLANK () )
    VAR minr =
        CALCULATE ( MIN ( 'Table'[Row] ), ALL ( 'Table' ), KEEPFILTERS ( k ) )
    RETURN
        IF ( 'Table'[Row] = minr, 'Table'[Column A], 0 - 'Table'[Column A] )
    
    new column B = 
    CALCULATE (
        SUM ( 'Table'[Column] ),
        FILTER ( 'Table', 'Table'[Row] <= EARLIER ( 'Table'[Row] ) )
    )