Forum Discussion

DanCasSan's avatar
DanCasSan
Helper V
6 years ago
Solved

Row_Number in column with DAX

Dear community:   I need your support. I want to perform an equivalency of the SQL ROW_NUMBER function on one of my tables in Power BI; basically, do what I put in the image. This equivalence shoul...
  • V-lianl-msft's avatar
    6 years ago

    Hi DanCasSan ,

     

    You can add an index column in query editor first.

    Then use the rankx function to create the calculated column.

    Rank =
    RANKX (
        FILTER (
            'Table',
            'Table'[KEYRATE] = EARLIER ( 'Table'[KEYRATE] )
                && 'Table'[PRDLIT] = EARLIER ( 'Table'[PRDLIT] )
        ),
        'Table'[Index],
        ,
        ASC
    )

    Sample .pbix 

     

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