Forum Discussion
JamesBurke
2 years agoHelper III
Rank
Hi All , I have a Ranking system : Rank =
VAR _RANK =
RANKX(FILTER(ALL('Emporia Devices'[Wawrick Device Name]) , 'Emporia Devices'[Wawrick Device Name] <> BLANK()), [Total solar Genera...
- Anonymous2 years ago
Thank you OwenAuger and SamWiseOwl
Hi, JamesBurke
Based on your descriptive information, as well as the example data provided and the expected output, I created the following example data:
I created a measure using this DAX expression below:
Rank = VAR _rank = RANK ( FILTER ( ALLSELECTED ( 'Emporia Devices' ), 'Emporia Devices'[Wawrick Device Name] <> BLANK () ), ORDERBY ( CALCULATE ( SUM ( 'Emporia Devices'[Total Solar Generated] ) ), DESC, CALCULATE ( MAX ( 'Emporia Devices'[Store Name] ) ), ASC ) ) RETURN IF ( SELECTEDVALUE ( 'Emporia Devices'[Wawrick Device Name] ) <> BLANK (), _rank, BLANK () )The results are as follows:
I have provided the PBIX file used in this instance below.
Best Regards
Jianpeng Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
OwenAuger
2 years agoSuper User
Hi JamesBurke
The RANK function is useful when you need to break ties like this.
Here is a suggested version of your measure using RANK and rewritten slightly:
Rank =
VAR SourceTable =
ADDCOLUMNS (
FILTER (
ALL ( 'Emporia Devices'[Wawrick Device Name] ),
NOT ISBLANK ( 'Emporia Devices'[Wawrick Device Name] )
),
"@TotalSolarGenerated", [Total solar Generated]
)
VAR _Rank =
RANK (
DENSE,
SourceTable,
ORDERBY (
[@TotalSolarGenerated], DESC,
'Emporia Devices'[Wawrick Device Name], ASC
)
)
RETURN
IF (
NOT ISBLANK ( MAX ( 'Emporia Devices'[Wawrick Device Name] ) ),
_Rank
)
Does this work at your end?
- SamWiseOwl2 years agoSuper User