Forum Discussion

Nikita's avatar
Nikita
New Member
9 years ago
Solved

How to add serial number based on another column values?

Hello, I'm just starting with Power BI and facing a problem. I have table which contains Person_Id and Order_Id. I want to create column which shows if it's first order of user or it's second order of user and so on. How can I achieve it? Is it possible in Query Editor?

Thanks in advance for answers.

  • Nikita

     

    According to your description, you actually need to add a rank column based on Order_Id group on Person_Id with Power Query. 

     

    For your requirement, you need to group all Order_Id entries into a Table object on Person_Id column. Then custom a Rank Function, invoke that function to add custom rank column in each grouped table object. After that, expand those tables. 

     

    For more details, you can refer to this article: Power Query function for dense ranking

     

    Regards,

5 Replies

  • v-sihou-msft's avatar
    v-sihou-msft
    Icon for Microsoft Employee rankMicrosoft Employee

    Nikita

     

    According to your description, you actually need to add a rank column based on Order_Id group on Person_Id with Power Query. 

     

    For your requirement, you need to group all Order_Id entries into a Table object on Person_Id column. Then custom a Rank Function, invoke that function to add custom rank column in each grouped table object. After that, expand those tables. 

     

    For more details, you can refer to this article: Power Query function for dense ranking

     

    Regards,

      • raynory's avatar
        raynory
        Regular Visitor

        Hi Tom - I run into a similar problem and the solution you mentioned could be exactly what I'm looking for. However the link is no longer valid. Is there any chance you can update it?

         

        Basically I need to rank / index a column but it should restart from 1 again on each subset. Thanks a lot.