Forum Discussion

fab196's avatar
fab196
Helper II
4 years ago
Solved

Sum OF values

Hi Everyone ,   need your help i want use power query and generate the result below   I have with two columns first is original col and second one is derived column as mentioned the below i wan...
  • amitchandak's avatar
    4 years ago

    fab196 , a new column

     

    new column =

    vat _b = [B]+0

    return

    countx(filter(Table, [A] = earlier([A]) && [B]+0 <= +b ), [A])

  • v-yanjiang-msft's avatar
    4 years ago

    Hi fab196 ,

    According to your description, it's more easier to achieve it by DAX, here's my solution.

    1.In Power Query, add an index column.

    Get this table.

    2.Create a calculated column.

    Count =
    VAR _RANK =
        RANKX (
            FILTER (
                ALL ( 'Table' ),
                'Table'[ColumnA] = EARLIER ( 'Table'[ColumnA] )
                    && 'Table'[ColumnB] = EARLIER ( 'Table'[ColumnB] )
                    && 'Table'[ColumnA] = 'Table'[ColumnB]
            ),
            'Table'[Index],
            ,
            ASC,
            DENSE
        )
    RETURN
        IF ( 'Table'[ColumnA] = 'Table'[ColumnB], _RANK + 1, _RANK )
    

    Get the expected result.

    I attach my sample below for reference.

     

    Best Regards,
    Community Support Team _ kalyj

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.