Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

How to index column on multiple values

This is the table I have PurchaseOrderNo ItemCode ItemCodeDesc QuantityOrdered QuantityReceived QuantityBackordered QuantityInvoiced RequiredDate PODATE Received 0096942 05-060 SET ...
  • v-yueyunzh-msft's avatar
    3 years ago

    Hi , Anonymous 

    According to your description, you want to "add an index that will index by the Requireddate and PO Number itemcode".

    For your data , in the [RequiredDate] has the same date , if in the normal rankx logic,it will returns 1 :

    If this meet your need , you just need to click "New Column" and enter this:

    Column = RANKX( FILTER('Table','Table'[PurchaseOrderNo]=EARLIER('Table'[PurchaseOrderNo]) && 'Table'[ItemCode] = EARLIER('Table'[ItemCode])) , [RequiredDate] ,,ASC,Dense)

     

    If you need to judge the row number for your data , you need to add an index column in Power Query Editor:

    Then you can click "New Column" and enter:

    Column 2 = RANKX( FILTER('Table','Table'[PurchaseOrderNo]=EARLIER('Table'[PurchaseOrderNo]) && 'Table'[ItemCode] = EARLIER('Table'[ItemCode])) , [RequiredDate]+[Index] ,,ASC,Dense)

     

    Then we can get the result:

    Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

     

    Best Regards,

    Aniya Zhang

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