Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount.
Register nowHi, All.
Can you help me with this?
I have this kind of table that consist of location, item, status, score, & target.
1Score2: =
Here is my expected Result:
Cases:
If the Status is "NEGATIVE" or "LOW", the Rank must start in the lowest value.
If the Status is "NORMAL" or HIGH, the Rank must start in the highest value.
See Examples Below:
Thanks in Advance.
Please refer to this link for my sample files:
https://drive.google.com/drive/folders/1jDjGSM9fxMoXg3hxIiNIaQQRbBb54Euj
Solved! Go to Solution.
Hi, @Nnamarie_1997
If you need to rank by measure [1Score2: ],please try measure like:
Rank(1Score2) =
VAR tab =
ADDCOLUMNS (
SUMMARIZE (
FILTER (
ALLSELECTED ( 'Table' ),
'Table'[LOCATION] = MAX ( 'Table'[LOCATION] )
&& 'Table'[STATUS] = MAX ( 'Table'[STATUS] )
),
'Table'[LOCATION],
'Table'[ITEM],
'Table'[STATUS]
),
"@1Score2", [1Score2:]
)
VAR CurrentValue = [1Score2:]
RETURN
SWITCH (
TRUE (),
SELECTEDVALUE ( 'Table'[STATUS] ) IN { "NEGATIVE", "LOW" }, RANKX ( tab, [@1Score2], CurrentValue, ASC, DENSE ),
SELECTEDVALUE ( 'Table'[STATUS] ) IN { "Normal", "High" }, RANKX ( tab, [@1Score2], CurrentValue, DESC, DENSE )
)
If you need to rank by field Table[SCORE],try measure like:
Rank(score) =
VAR tab =
FILTER (
ALLSELECTED ( 'Table' ),
'Table'[LOCATION] = MAX ( 'Table'[LOCATION] )
&& 'Table'[STATUS] = MAX ( 'Table'[STATUS] )
)
RETURN
SWITCH (
TRUE (),
SELECTEDVALUE( 'Table'[STATUS] ) IN { "NEGATIVE", "LOW" }, RANKX ( tab, CALCULATE ( MAX ( 'Table'[SCORE] ) ),, ASC, DENSE ),
SELECTEDVALUE('Table'[STATUS] ) IN { "Normal", "High" }, RANKX ( tab, CALCULATE ( MAX ( 'Table'[SCORE] ) ),, DESC, DENSE )
)
Best Regards,
Community Support Team _ Eason
Hi, @Nnamarie_1997
Not quite understand what you mean. From your formula, the value of rank should depend on the value of [1Score2:].
What is your expected result?
Best Regards,
Community Support Team _ Eason
Hi @v-easonf-msft ,
Sorry for Late Reply.
Here is my expected result.
Cases:
If the Status is "NEGATIVE" or "LOW", the Rank must start in the lowest value.
If the Status is "NORMAL" or HIGH, the Rank must start in the highest value.
See Examples Below:
Thank You..
Hi, @Nnamarie_1997
If you need to rank by measure [1Score2: ],please try measure like:
Rank(1Score2) =
VAR tab =
ADDCOLUMNS (
SUMMARIZE (
FILTER (
ALLSELECTED ( 'Table' ),
'Table'[LOCATION] = MAX ( 'Table'[LOCATION] )
&& 'Table'[STATUS] = MAX ( 'Table'[STATUS] )
),
'Table'[LOCATION],
'Table'[ITEM],
'Table'[STATUS]
),
"@1Score2", [1Score2:]
)
VAR CurrentValue = [1Score2:]
RETURN
SWITCH (
TRUE (),
SELECTEDVALUE ( 'Table'[STATUS] ) IN { "NEGATIVE", "LOW" }, RANKX ( tab, [@1Score2], CurrentValue, ASC, DENSE ),
SELECTEDVALUE ( 'Table'[STATUS] ) IN { "Normal", "High" }, RANKX ( tab, [@1Score2], CurrentValue, DESC, DENSE )
)
If you need to rank by field Table[SCORE],try measure like:
Rank(score) =
VAR tab =
FILTER (
ALLSELECTED ( 'Table' ),
'Table'[LOCATION] = MAX ( 'Table'[LOCATION] )
&& 'Table'[STATUS] = MAX ( 'Table'[STATUS] )
)
RETURN
SWITCH (
TRUE (),
SELECTEDVALUE( 'Table'[STATUS] ) IN { "NEGATIVE", "LOW" }, RANKX ( tab, CALCULATE ( MAX ( 'Table'[SCORE] ) ),, ASC, DENSE ),
SELECTEDVALUE('Table'[STATUS] ) IN { "Normal", "High" }, RANKX ( tab, CALCULATE ( MAX ( 'Table'[SCORE] ) ),, DESC, DENSE )
)
Best Regards,
Community Support Team _ Eason
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
User | Count |
---|---|
24 | |
14 | |
13 | |
12 | |
7 |
User | Count |
---|---|
30 | |
22 | |
15 | |
14 | |
14 |