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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
DK-C-87
Helper I
Helper I

RankX on a table with multiple filters

I need this measure to give me a ranking from 1-21 in my visual, which it dosen't do at the moment

Measure = 
IF(HASONEFILTER(ProcesGBS[Proces]),
    RANKX(ALLSELECTED(ProcesGBS),
        CALCULATE(SUM(ProcesGBS[Timer Norma RAW CM (ProcesID)]),
        FILTER(ALL(Stamdata), Stamdata[Plant] <> BLANK()))),
        BLANK()
    )

My table visual

DKC87_0-1734506370247.png

I'm using ALLSELECTED because I have multiple filters set up specific for this table visual.

The table only shows these 21 rows in the visual, but it looks like the rankx measure catches more and therefore gets me as much as ranking 1730

 

Can anyone crack this mistory ?

1 ACCEPTED SOLUTION

In the screenshot below I am using the following measures. Notice that evaluated correctly.

Total Revenue ALLDATES 2023 = 
CALCULATE ( [Total Revenue], FILTER ( ALL ( Dates ), Dates[Year] = 2023 ) )

RANK = 
RANKX (
    ALL ( Category[Category] ),
    [Total Revenue ALLDATES 2023],
    ,
    DESC,
    DENSE
)

danextian_0-1734514957870.png

Now, if i add another column, the rank for the column in rankx and the additional column is evaluated differently.

danextian_1-1734515029247.png

Things to check:

  • are you using just the column specified in the rankx measure or are there more columns?
  • is the expression the rank is based on returning the correct value?









Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

12 REPLIES 12
Bibiano_Geraldo
Super User
Super User

Hi @DK-C-87 ,
To ensure that the ranking is limited to the 21 rows shown in your visual, you can adjust your measure to better respect the current filter context.

Please consider this updated DAX and let me know if its all ok:

Measure = 
IF(
    HASONEFILTER(ProcesGBS[Proces]),
    RANKX(
        ALLSELECTED(ProcesGBS[Proces]),
        CALCULATE(
            SUM(ProcesGBS[Timer Norma RAW CM (ProcesID)]),
            FILTER(
                ALL(Stamdata),
                Stamdata[Plant] <> BLANK()
            )
        ),
        ,
        DESC,
        DENSE
    ),
    BLANK()
)

 

Is this post help you? Please consider to:

Accept as Solution!
Give a Kudo
Follow me on Linkedin

Your measure returns this for me:

DKC87_0-1734510790731.png


Do you have a suggestion to why this is ? 

Can you please share a sample file with no sensitive information?

 

Your screenshot is not whowing entire table.

 

You can upload a sample file in onedrive or other cloud and share the link for download here in comments.

 

 

Is this post help you? Please consider to:

Accept as Solution!
Give a Kudo
Follow me on Linkedin

Sorry, I can't share sample file. 
I am filtering on 3 columns and are only showing 1 of these three filtret columns in the visuals table - could it be the problem here ? 
Maybe the measure should summarize first and then rank on that ? 

Are you using the process column in your viz?










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

You mean my visual 🙂
Yes, I am using the Proces column in my visual - it is the first column in the visual. 

In the screenshot below I am using the following measures. Notice that evaluated correctly.

Total Revenue ALLDATES 2023 = 
CALCULATE ( [Total Revenue], FILTER ( ALL ( Dates ), Dates[Year] = 2023 ) )

RANK = 
RANKX (
    ALL ( Category[Category] ),
    [Total Revenue ALLDATES 2023],
    ,
    DESC,
    DENSE
)

danextian_0-1734514957870.png

Now, if i add another column, the rank for the column in rankx and the additional column is evaluated differently.

danextian_1-1734515029247.png

Things to check:

  • are you using just the column specified in the rankx measure or are there more columns?
  • is the expression the rank is based on returning the correct value?









Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Things to check:

  • are you using just the column specified in the rankx measure or are there more columns?
    • This question did it for me 🙂
  • is the expression the rank is based on returning the correct value?

    Thank you so much for your help !
Kedar_Pande
Super User
Super User

@DK-C-87 

Here's a refined measure that you can use:

Measure =
IF(
HASONEFILTER(ProcesGBS[Proces]),
RANKX(
FILTER(
ALLSELECTED(ProcesGBS),
NOT(ISBLANK(SUM(ProcesGBS[Timer Norma RAW CM (ProcesID)])))
),
CALCULATE(
SUM(ProcesGBS[Timer Norma RAW CM (ProcesID)]),
FILTER(ALL(Stamdata), Stamdata[Plant] <> BLANK())
),
,
DESC,
DENSE
),
BLANK()
)

Let me know if you have any further questions or need additional adjustments!

 

💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

 

Your measure returns this for me :

DKC87_1-1734510994395.png


A small different, but still not solved - do you have a suggestion ?

danextian
Super User
Super User

Hi @DK-C-87 

The rank is calculated in the context of other selected rows in the ALLSELECTED(ProcesGBS) table. Rank is supposed to be applied to a column and not a table.










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

If I change the allselected to a column like this : 

 

 

IF(HASONEFILTER(ProcesGBS[Proces]),
    RANKX(ALLSELECTED(ProcesGBS[Proces]),
        CALCULATE(SUM(ProcesGBS[Timer Norma RAW CM (ProcesID)]),
        FILTER(ALL(Stamdata), Stamdata[Plant] <> BLANK()))),
        BLANK()
    )

 

 


Then I get this result : 

DKC87_0-1734514729558.png

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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