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

PurchaseOrderNoItemCodeItemCodeDescQuantityOrderedQuantityReceivedQuantityBackorderedQuantityInvoicedRequiredDatePODATEReceived
009694205-060SET SPRING,  .177 DIA 17-7 STA25250257/15/20203/20/2020 0:00R
009694205-060SET SPRING,  .177 DIA 17-7 STA52552505259/1/20203/20/2020 0:00R
009694205-060SET SPRING,  .177 DIA 17-7 STA50050005008/3/20203/20/2020 0:00R
009900205-060SET SPRING,  .177 DIA 17-7 STA2002000285/24/20212/4/2021 0:00R
009900205-060SET SPRING,  .177 DIA 17-7 STA20020002005/24/20212/4/2021 0:00R
009900205-060SET SPRING,  .177 DIA 17-7 STA20020002005/24/20212/4/2021 0:00R
009974905-060SET SPRING,  .177 DIA 17-7 STA35035003506/15/20214/29/2021 0:00R
009974905-060SET SPRING,  .177 DIA 17-7 STA30530503057/15/20214/29/2021 0:00R
010052205-060SET SPRING,  .177 DIA 17-7 STA35035003509/29/20216/29/2021 0:00R
010052205-060SET SPRING,  .177 DIA 17-7 STA35035003509/29/20216/29/2021 0:00R
010184105-060SET SPRING,  .177 DIA 17-7 STA40040004005/4/202210/27/2021 0:00R
010184105-060SET SPRING,  .177 DIA 17-7 STA40040004005/4/202210/27/2021 0:00R
010277605-060SET SPRING,  .177 DIA 17-7 STA30030003004/26/202212/29/2021 0:00R
010277605-060SET SPRING,  .177 DIA 17-7 STA30030003004/26/202212/29/2021 0:00R
010350905-060SET SPRING,  .177 DIA 17-7 STA25025002504/15/20222/28/2022 0:00R
010350905-060SET SPRING,  .177 DIA 17-7 STA25025002506/17/20222/28/2022 0:00R
010350905-060SET SPRING,  .177 DIA 17-7 STA250250008/1/20222/28/2022 0:00R
010350905-060SET SPRING,  .177 DIA 17-7 STA25025005007/11/20222/28/2022 0:00R
010525405-060SET SPRING,  .177 DIA 17-7 STA550550055011/30/20228/8/2022 0:00R
010525405-060SET SPRING,  .177 DIA 17-7 STA550550055011/30/20228/8/2022 0:00R
010652705-060SET SPRING,  .177 DIA 17-7 STA5000002/28/20231/4/2023 0:00 
010652705-060SET SPRING,  .177 DIA 17-7 STA2500006/30/20231/4/2023 0:00 
0106527

05-060SET SPRING,  .177 DIA 17-7 STA2500009/1/20231/4/2023 0:00 



I need to add an index that will index by the Requireddate and PO Number itemcode. So I would expect my results to look like this: 

PurchaseOrderNoItemCodeItemCodeDescQuantityOrderedQuantityReceivedQuantityBackorderedQuantityInvoicedRequiredDatePODATEReceivedIndex
009694205-060SET SPRING,  .177 DIA 17-7 STA25250257/15/20203/20/2020 0:00R1
009694205-060SET SPRING,  .177 DIA 17-7 STA52552505259/1/20203/20/2020 0:00R2
009694205-060SET SPRING,  .177 DIA 17-7 STA50050005008/3/20203/20/2020 0:00R3
009900205-060SET SPRING,  .177 DIA 17-7 STA2002000285/24/20212/4/2021 0:00R1
009900205-060SET SPRING,  .177 DIA 17-7 STA20020002005/24/20212/4/2021 0:00R2
009900205-060SET SPRING,  .177 DIA 17-7 STA20020002005/24/20212/4/2021 0:00R3
009974905-060SET SPRING,  .177 DIA 17-7 STA35035003506/15/20214/29/2021 0:00R1
009974905-060SET SPRING,  .177 DIA 17-7 STA30530503057/15/20214/29/2021 0:00R2
010052205-060SET SPRING,  .177 DIA 17-7 STA35035003509/29/20216/29/2021 0:00R1
010052205-060SET SPRING,  .177 DIA 17-7 STA35035003509/29/20216/29/2021 0:00R2
010184105-060SET SPRING,  .177 DIA 17-7 STA40040004005/4/202210/27/2021 0:00R1
010184105-060SET SPRING,  .177 DIA 17-7 STA40040004005/4/202210/27/2021 0:00R2
010277605-060SET SPRING,  .177 DIA 17-7 STA30030003004/26/202212/29/2021 0:00R1
010277605-060SET SPRING,  .177 DIA 17-7 STA30030003004/26/202212/29/2021 0:00R2
010350905-060SET SPRING,  .177 DIA 17-7 STA25025002504/15/20222/28/2022 0:00R1
010350905-060SET SPRING,  .177 DIA 17-7 STA25025002506/17/20222/28/2022 0:00R2
010350905-060SET SPRING,  .177 DIA 17-7 STA250250008/1/20222/28/2022 0:00R3
010350905-060SET SPRING,  .177 DIA 17-7 STA25025005007/11/20222/28/2022 0:00R4
010525405-060SET SPRING,  .177 DIA 17-7 STA550550055011/30/20228/8/2022 0:00R1
010525405-060SET SPRING,  .177 DIA 17-7 STA550550055011/30/20228/8/2022 0:00R2
010652705-060SET SPRING,  .177 DIA 17-7 STA5000002/28/20231/4/2023 0:00 1
010652705-060SET SPRING,  .177 DIA 17-7 STA2500006/30/20231/4/2023 0:00 2
010652705-060SET SPRING,  .177 DIA 17-7 STA2500009/1/20231/4/2023 0:00 3

 Is this possible to do?

  • 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

1 Reply

  • 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