Forum Discussion

JofrainVisda's avatar
JofrainVisda
Advocate I
2 years ago
Solved

Row Number

Hi Friends, I would like to achieve this. Is this possible with DAX? I would like to put a row number for each occurence of the column 1. Thank you in advance!  
  • TomMartens's avatar
    2 years ago

    Hey JofrainVisda ,

     

    I think you can achieve this if you are able to add a column to your table that acts as a ro identifier:

    Then you can add the below DAX to create the column you are looking for:

    Column = 
    ROWNUMBER(
        SUMMARIZE(
            ALLSELECTED( 'Table')
            , 'Table'[item]
            , 'Table'[rowindex]
        )
        , ORDERBY( 'Table'[rowindex])
        , DEFAULT
        , PARTITIONBY( 'Table'[item] )
    )

    RANKX will not work because of

    • you have to partition by the single occurences and
    • you have to consider the ties, RANKX will never provide consecutive numbers for the same value.

    Hopefully, this helps to tackle your challenge.

     

    Regards,

    Tom