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

View all the Fabric Data Days sessions on demand. View schedule

Reply
Lobo1908
Helper I
Helper I

Rank the string according to the highest rank value in it.

Hi, 

 

I have a lookup table with a list of codes and a rank assigned against each code.
The lookup table looks as follows:

CodeRank 
DI9001   1
DI2102   1
DI0303   2
DI0404   2
DI6005   3
DI5006   3 
DI0307   3
DI0018   4
DI0019   4
DI0020   4

 

I also have a data table with a string of codes assigned to parts. 

Please see below:

 

Part #Codes 
Part 1 DI9001 DI2102 DI6005
Part 2DI9001 DI0020 DI5006
Part 3DI9001
Part 4DI5006
Part 5DI0307
Part 6 
Part 7DI9001 DI0020
Part 8DI9001 DI0303
Part 9DI0307 DI0020
Part 10DI0020 DIV090

 

 

Please note that in the string there are values that should be ingored as they are not present in the lookup table.

In this eg it is DIV090.

 

What I'm looking for is for power bi to review the stirng of codes and assigned rank to the part based on the highest ranked code in the string according to the lookup table

 

Solution should look as follow.

 

 

Part #Codes Rank
Part 1 DI9001 DI2102 DI6005   3
Part 2DI9001 DI0020 DI5006   4
Part 3DI9001   1
Part 4DI5006   3
Part 5DI0307   3
Part 6  
Part 7DI9001 DI0020   4
Part 8DI9001 DI0303   2
Part 9DI0307 DI0020   4
Part 10DI0020 DIV090   4

 

 

Could someone support please.

1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @Lobo1908 

the solution consists 3 steps:

1) split the codes column to rows with Power Query, 

2) connect the splitted table with the lookup table

3) get the expected RankTable

 

here comes the details:

1) split to rows

image.png

2) connect with the lookup table

FreemanZ_1-1670250186538.png

 

3) create a new table with this:

RankTable =
ADDCOLUMNS(
    VALUES(TableName[PartNo]),
    "Rank",
    CALCULATE(
        MAXX(
            TableName,
            RELATED(Lookup[Rank])
        )
    )
)

 

the result looks like this:

FreemanZ_0-1670250162869.png

 

View solution in original post

1 REPLY 1
FreemanZ
Super User
Super User

hi @Lobo1908 

the solution consists 3 steps:

1) split the codes column to rows with Power Query, 

2) connect the splitted table with the lookup table

3) get the expected RankTable

 

here comes the details:

1) split to rows

image.png

2) connect with the lookup table

FreemanZ_1-1670250186538.png

 

3) create a new table with this:

RankTable =
ADDCOLUMNS(
    VALUES(TableName[PartNo]),
    "Rank",
    CALCULATE(
        MAXX(
            TableName,
            RELATED(Lookup[Rank])
        )
    )
)

 

the result looks like this:

FreemanZ_0-1670250162869.png

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors