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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Ranking Total Issue.

Hi All,

I'm having incorrect Rankx Total on my measure whenever i filter on fiscal Year 2022, then when i filter fiscal year 2021 it works pperfectly. The RankTotal changes to 13 which is incorrect instead of 12 for only 2022. see screem shot & code below. 
VAR _DivisonRanking =
IF (
NOT ISBLANK( [Percent] ),
CALCULATE (
RANKX (
FILTER ( ALL ( dim_sites[Division] ), NOT ISBLANK( [Percent] ) ),
[Percent],
,
DESC,
DENSE
),
ALL ( dim_sites[Region] ),
ALL ( dim_sites[Site_District] ),
ALL ( dim_sites[Site_Name] )
)
)
VAR _RegionRanking =
IF (
NOT ( ISBLANK( [Percent] ) ),
CALCULATE (
RANKX (
FILTER ( ALL ( dim_sites[Region] ), NOT ( ISBLANK( [Percent] ) ) ),
[Percent] ,
,
DESC,
DENSE
),
ALL ( dim_sites[Site_District] ),
ALL ( dim_sites[Site_Name] ),
ALLSELECTED ( dim_sites[Division] )
)
)
VAR _MarketRanking =
IF (
NOT ( ISBLANK( [Percent] ) ),
CALCULATE (
RANKX (
FILTER ( ALL ( dim_sites[Site_District] ), NOT ( ISBLANK( [Percent] ) ) ),
[Percent],
,
DESC,
DENSE
),
ALL ( dim_sites[Site_Name] ),
ALLSELECTED ( dim_sites[Region] ),
ALLSELECTED ( dim_sites[Division] )
)
)
VAR _SiteRanking =
IF (
NOT ( ISBLANK( [Percent] ) ),
CALCULATE (
RANKX (
FILTER ( ALL ( dim_sites[Site_Name] ), NOT ( ISBLANK( [Percent] ) ) ),
[Percent],
,
DESC,
DENSE
),
ALLSELECTED ( dim_sites[Region] ),
ALLSELECTED ( dim_sites[Site_District] ),
ALLSELECTED ( dim_sites[Division] )
)
)
VAR _Results =
SWITCH (
TRUE (),
HASONEFILTER ( dim_sites[Site_Name] ), _SiteRanking,
HASONEFILTER ( dim_sites[Site_District] ), _MarketRanking,
HASONEFILTER ( dim_sites[Region] ), _RegionRanking,
HASONEFILTER ( dim_sites[Division] ), _DivisonRanking,
BLANK ()
)
RETURN
_Results

Iklizo_0-1652721499055.png

 

1 ACCEPTED SOLUTION
Whitewater100
Solution Sage
Solution Sage

Hi:

Would this streamline it a bit? For each level

 Site Rank = IF (
NOT ( ISBLANK( [Percent] ) ), RANKX(ALL(dim_sites[Site_Name] ), [Percent],  DESC))

View solution in original post

5 REPLIES 5
Whitewater100
Solution Sage
Solution Sage

Hi:

Would this streamline it a bit? For each level

 Site Rank = IF (
NOT ( ISBLANK( [Percent] ) ), RANKX(ALL(dim_sites[Site_Name] ), [Percent],  DESC))

Anonymous
Not applicable

@Whitewater100   it works for 1 row. but, i need it to work for multiple rows total. see screen shot. 

Iklizo_0-1652733610847.png

 

OK. Maybe the INSCOPE is better:

 

Rank In Scope = IF(

ISINSCOPE(dim_sites[Site_District]), RANKX(ALL(dim_sites[Site_District]),

[Percent]),

IF(

ISINSCOPE(dim_sites[Region]),

RANKX(ALLSELECTED(dim_sites[Region]),

[Percent]),

IF(

ISINSCOPE(dim_sites[Division] ),

RANKX(ALLSELECTED(dim_sites[Division] ),

[Percent])

)

)

Anonymous
Not applicable

@Whitewater100  The incsope didn't work either , the first code is better. can we not rank blanks for first code. 

Iklizo_0-1652737487453.png

 

Hi lklizo:

If possible, would you be able to send me reprentative data? I will get it but easier if I can see your set up. Thanks for your patience..

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.