Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

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?

1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

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 :

vyueyunzhmsft_0-1678334037157.png

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:

vyueyunzhmsft_1-1678334124228.png

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:

vyueyunzhmsft_2-1678334156015.png

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

View solution in original post

1 REPLY 1
v-yueyunzh-msft
Community Support
Community Support

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 :

vyueyunzhmsft_0-1678334037157.png

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:

vyueyunzhmsft_1-1678334124228.png

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:

vyueyunzhmsft_2-1678334156015.png

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.