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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Tlotly
Resolver II
Resolver II

RankX with blank column rows issue (related tables)

Good day

 

I've been having endless issues with Ranking that I decided to start the report from scratch. So I now have two tables, PAR and Branch Details. Reason for having Branch Details table is, I will have to add other tables which will link to Branch Details as the report is Branch ranking, where I have to rank branches based on multiple measures, hence multiple tables. 

 

Below is my data model:

Tlotly_0-1695894203536.png

 

So as a start, I'm ranking on one measure i.e. Percentage. The ranking works when I use the Branch Name for the fact table (PAR), as seen below:

     

RankbyPerc = var _perc = CALCULATE(SUM(PAR[Percentage]))

RETURN

RANKX(ALL(PAR[Branch Name]), CALCULATE(sum(PAR[Percentage])), , ASC, Dense)

Tlotly_1-1695894349667.png

 

As soon as I start using the Branch name from the linked table Branch Details which I have to use when I add more tables, the Ranking breaks. This is because there are some branches on the PAR table which are not on the Branch Details table. This is correct as there was nothing on them for the month I'm looking at so I cannot exclude them from the report.

 

Tlotly_2-1695894528479.png

So to get around this, I added a condition to check for blanks, which seems to work but the problem is, it's starting at 2:

RankbyPerc = var _perc = CALCULATE(SUM(PAR[Percentage]))

RETURN

IF(NOT(ISBLANK(_perc)),

RANKX(ALL('Branch Details'[description]), CALCULATE(sum(PAR[Percentage])), , ASC, Dense),BLANK())

Tlotly_3-1695895090297.png


I even tried this formula, but it ranks everything as 1:

RankbyPerc = var _perc = CALCULATE(SUM(PAR[Percentage]))

RETURN IF (

    ISBLANK ( _perc) = FALSE (),

    RANKX (

        ALL ( 'Branch Details'[description] ),

        CALCULATE (

            _perc,

            ALLEXCEPT ( 'Branch Details', 'Branch Details'[description] )

        )

    )

)

Tlotly_5-1695895561083.png

Please assist.

Thanking you in advance.

 



1 REPLY 1
lbendlin
Super User
Super User

Please provide sample data (with sensitive information removed) that covers your issue or question completely, in a usable format (not as a screenshot). Leave out anything not related to the issue.
If you are unsure how to do that please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.

If you want to get answers faster please refer to https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.