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.
SamWiseOwl
2 years agoSuper User
Hi JamesBurke
Modified Rank =
var _sales = [Total solar Generated]
VAR _RANK =
RANKX(FILTER(ALL('Emporia Devices'[Wawrick Device Name]) , 'Emporia Devices'[Wawrick Device Name] <> BLANK()), [Total solar Generated],,DESC,Skip)
--var _test = RANKX(all('Emporia Devices'),[Wawrick Device Name],,DESC)
var matches = RANK(DENSE,FILTER(ALL('Emporia Devices'), [Total solar Generated] = _sales),ORDERBY([Wawrick Device Name]))
RETURN
IF(
HASONEVALUE('Emporia Devices'[Wawrick Device Name]) ,
_RANK+ ( matches-1),
BLANK()
)
First calculate and store the current sales.
Then do the rank as normal using SKIP to create gaps.
Rank again but only items that have the same sales as the current row.
Add this secondary rank onto the first rank less 1.