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
Anonymous
Not applicable

RANKX not operating on correct level

Hi all,

 

I'm trying to rank blog posts by view count, but for some reason it's ranking the only each author's posts amongst themselves, as opposed to looking over the entire dataset to rank page vs page. Has anyone got a clue how to fix this?

 

 

Page Rank = 
RANKX(ALL('Hub Page Data'),[Sum of page views],1,0)

 

 

Ranking Issue.png

 

Kind regards,

 

Jordan 

11 REPLIES 11
selimovd
Super User
Super User

Hey @Anonymous ,

 

from which tables do you use the all the column in this table?

Could you provide the file if the content is not sensitive? This would make it easier to find the error.

 

Thank you and best regards

Denis

 

Anonymous
Not applicable

@selimovd Hi Denis,

 

Link to 1 Drive file is below. Thank you for looking into this for me!

https://1drv.ms/u/s!Aox2dQrFw5CYhmw7uhP80MiXp7Fz?e=ymowis 

 

Kind regards,

 

Jordan 

Hey @Anonymous ,

 

in this case you have to follow 2 things:

1. Make the whole table available with ALL()

2. Use context transition for the measure itself with CALCULATE

 

So the following measure gives you the rank:

Rank New User =
RANKX(
    ALL( 'All Web Site Data' ),
    CALCULATE( SUM( 'All Web Site Data'[New Users] ) )
)

 

Let me know if that works and if you can transition that to your original problem.

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 
aj1973
Community Champion
Community Champion

Hi @Anonymous 

Use you Rank measure this way 

Page Rank =
RANKX(ALL('Hub Page Data'),[Sum of page views], ,DESC)

no need for 1 and 0

 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Anonymous
Not applicable

still no luck 😞 

image.png

aj1973
Community Champion
Community Champion

Hi @Anonymous 

You need to first add a separate measure 

Sum Users = SUM('All Web Site Data'[New Users])
 
then add another measure
Rank = RANKX(ALL('All Web Site Data'), [Sum Users] )
aj1973_0-1616416669081.png

 

By the way @selimovd we use CALCULATE only when we need to filter an expression.

 

 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

@aj1973 

Using a measure triggers context transition or using CALCULATE triggers context transition.

In general, we use CALCULATE when we modify the filter context, not only when we filter an expression, or we use it when we have to trigger context transition like in this case.

 

So both of our solutions are doing the same, your solution with an additional measure, mine with one measure.

 

Also, check the article from SQLBI, this will help you to understand context transition a little better:

Understanding Context Transition - SQLBI

 

But your approach is also totally fine.

 

Best regards

Denis

aj1973
Community Champion
Community Champion

@selimovd 

Well my apologies, may be I should have said " Better use CALCULATE to filter an expression ".

Peace 😁

 

 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

@aj1973 Was not meant in an offensive way, I also just recently found out about the context transition with Calculate only 😉

But it's pretty mind blowing once you dig a little deeper.

 

But as I said when you have 2 measures, your solution is perfect.

 

Best regards

Denis

 

 

Anonymous
Not applicable

Hi @pranit828 ,
 
I tried this but it seemed to make no difference. What else could I try?

 

 

Page Rank = 

RANKX(ALLEXCEPT('Hub Page Data','Hub Page Data'[Creator],'Hub Page Data'[Page Title]),'Hub Page Data'[Sum of page views])​

 

 

image.png

 

Kind regards,

 

Jordan 

pranit828
Community Champion
Community Champion

Hi @Anonymous 

Please try the below DAX

 

RANKX(ALLEXPECT(Table,Table[Creator],Table[Page Title]),Table[Views])




PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile

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.