Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

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)

 

 

 

Kind regards,

 

Jordan 

11 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous 

    Please try the below DAX

     

    RANKX(ALLEXPECT(Table,Table[Creator],Table[Page Title]),Table[Views])
  • Anonymous's avatar
    Anonymous
    Not applicable
    Hi Anonymous ,
     
    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])​

     

     

     

    Kind regards,

     

    Jordan 

  • aj1973's avatar
    aj1973
    Icon for Community Champion rankCommunity 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

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      still no luck 😞 

      • aj1973's avatar
        aj1973
        Icon for Community Champion rankCommunity 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] )

         

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

         

         

  • selimovd's avatar
    selimovd
    Icon for Most Valuable Professional rankMost Valuable Professional

    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

     

      • selimovd's avatar
        selimovd
        Icon for Most Valuable Professional rankMost Valuable Professional

        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