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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
therealomacoder
Helper II
Helper II

Ranking Based Upon Column in Scope, Ties Broken based upon another measure, Don't Rank Blanks()

Yes, another ranking question! After 2 days of reading and debugging on my own, I've decided it's time to ask you gurus.

How do I fix my ranking so that it ranks all the way to #10, rather than stopping when positive numbers in the rank turn negative?

 

therealomacoder_0-1668329802657.png

Metric to Analyze (Rank Top 10) = 

var varRank = 
SWITCH(
    [Current Hierarchy Scope]
        ,"Zip",[Rank by Zip (Top 10)]
        ,"County",[Rank by County (Top 10)]
        ,"Metro",[Rank by Metro (Top 10)]
    )
    
RETURN
varRank

 

Rank by Metro (Top 10) = 

var varRank = RANKX(ALL('Geo - Core Based Statistical Area'), 
    RANKX (ALL('Geo - Core Based Statistical Area'), CALCULATE([Metric to Analyze (not formatted)])
        + 1-DIVIDE( 
            [Residential Mail Delivery Points (Per 1K)], 
            100000000
        )
, , ASC))
RETURN
IF (varRank <=10,varRank,Blank())

 

Current Hierarchy Scope = 
IF ( ISINSCOPE('Geo - Postal Code'[Zip]),"Zip",
IF ( ISINSCOPE('Geo - County'[County & State]),"County",
IF ( ISINSCOPE('Geo - Core Based Statistical Area'[Metro]),"Metro",
IF (ISINSCOPE('Geo - State'[State]),"Nationwide"))))

 

Selection Choice: Rank ID = SELECTEDVALUE('Rank By'[Rank By ID])

 

Metric to Analyze (not formatted) = 

VAR varSelection = [Selection Choice: Rank ID]
RETURN
    SWITCH (
        TRUE (),
        varSelection = 1, [Notice Count],
        varSelection = 2, [Notice Count to Housing Units Ratio],
        varSelection = 3, [% Change]
    )

 

Residential Mail Delivery Points (Per 1K) = DIVIDE([Residential Mail Delivery Points],1000)

 

Residential Mail Delivery Points = CALCULATE(sum('Geo - Census By Postal Code'[ResidentialMailDeliveryPointCnt]))

 

Notice Count to Housing Units Ratio = 

VAR varSelectedNotice = [Selection Choice: Notice Code]
RETURN
    SWITCH (
        TRUE (),
        varSelectedNotice = "NOD/LIS", [NOD/LIS % of Residental Deliveries],
        varSelectedNotice = "NFS/NTS", [NTS/NFS % of Residental Deliveries],
        varSelectedNotice = "NOD", [NOD % of Residental Deliveries],
        varSelectedNotice = "LIS", [LIS % of Residental Deliveries],
        varSelectedNotice = "NTS", [NTS % of Residental Deliveries],
        varSelectedNotice = "NFS", [NFS % of Residental Deliveries],
        varSelectedNotice = "REO", [REO % of Residental Deliveries]
    )+0

 

NOD % of Residental Deliveries = DIVIDE([NOD],[Residential Mail Delivery Points (Per 1K)])

 

NOD = sum('ATTOM Data - Foreclosure'[NOD_NoticeOfDefaultCnt])+0

 

1 ACCEPTED SOLUTION
therealomacoder
Helper II
Helper II

Well isn't that funny - I guess it just took me writing out all of the steps and digging into the problem in a bit more detail helped me find the solution.


ALLSELECTED, in all occurrences, vs ALL.

 

"If you forget to ignore the filter context and use VALUES instead of ALLSELECTED, then..."

 

Discovered here.

This is by far the best write up I've found of Rankx over the past couple days that I've been looking.



View solution in original post

1 REPLY 1
therealomacoder
Helper II
Helper II

Well isn't that funny - I guess it just took me writing out all of the steps and digging into the problem in a bit more detail helped me find the solution.


ALLSELECTED, in all occurrences, vs ALL.

 

"If you forget to ignore the filter context and use VALUES instead of ALLSELECTED, then..."

 

Discovered here.

This is by far the best write up I've found of Rankx over the past couple days that I've been looking.



Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors