Forum Discussion
Find a code in a string with the highest rank
- Anonymous3 years ago
Hi Lobo1908 ,
I have created a simple sample, please refer to it to see if it helps you.
Create measures.
code1 = RIGHT(MAX('Table'[Code]),2)Measure = VAR _1 = RIGHT ( MAX ( 'Table (2)'[Codes ] ), 2 ) RETURN CALCULATE ( MAX ( 'Table'[Rank ] ), FILTER ( ALL ( 'Table' ), [code1] = _1 ) )How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Lobo1908 ,
I have created a simple sample, please refer to it to see if it helps you.
Create measures.
code1 = RIGHT(MAX('Table'[Code]),2)Measure =
VAR _1 =
RIGHT ( MAX ( 'Table (2)'[Codes ] ), 2 )
RETURN
CALCULATE ( MAX ( 'Table'[Rank ] ), FILTER ( ALL ( 'Table' ), [code1] = _1 ) )
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Lobo19083 years agoHelper I
Hi,
This basically does what I've asked for.
Unfortunately, I've simplified the example too much and is not take into considerattions some factors.
1st - my list of fault codes is much larger and some of them have a high code number but low rank e.g
Code Rank DI9001 1 DI2102 1 DI0303 2 DI0404 2 DI6005 3 DI5006 3 DI0307 3 DI0018 4 DI0019 4 DI0020 4 2 thing my code use 4 numebr insted of 2
I've manage to solve that by increasing the number form 2 to 4 in both measures.
This has created a 3rd issue, in some strings there is a value DIV090.
Every time this is present in the string the rank is blank.
I was trying to fix this by applying a step and converting DIV090 to DI0000 with rank 0.
Now everytime there is DI0000 in the string it applies rank 0 to the part even if higher rank code is present.
Following the logic in your measure it is using the fact that the codes and ranks are set in asscending order and again this is what I asked for. Unfortunetly, that doesn't solve my issue.
I've raised a new question with new data in the following thread:
Rank the string according to the highest rank valu... - Microsoft Power BI Community