Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Dynamic ranking based on slicer selection

Hi All -- Need one help with dynamic ranking based on slicer selection. Link has the PBIX file along with data. What I am trying to see is based on my year / month / quarter selection it should give correct ranking in the table like 1,2,3 ...

 

PBIX Code and Data Source 

11 Replies

  • Hi,

    It works fine.  See the highlighted portion in the image

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you. That helped

    • rishikhurana's avatar
      rishikhurana
      Regular Visitor

      Hi Ashish,

       

      Solution is great however, I have a quick question related to this if you can please answer?

       

      I am making a selection through Slicer/Filters where in the background data I have 42 distinct rows. When I create this rank formula, it assigns rank to all 42 but doesnt change (reduce) if i filter few through selection. Like I am making a selection that results in 8 data points, the column technically assign rank till 8 and not all 42 correct?

       

      Please help?

       

      Thanks

      • Ashish_Mathur's avatar
        Ashish_Mathur
        Icon for Super User rankSuper User

        Thank you.  That is an sold post.  Please describe your question, share some data and show the expected result.

  • smpa01's avatar
    smpa01
    Icon for Community Champion rankCommunity Champion

    Anonymous  please try this and test the output

     

    Measure 6 =
    RANKX (
        CALCULATETABLE (
            VALUES ( Sale[Sales Person] ),
            FILTER (
                ALLSELECTED ( Sale ),
                Sale[Date].[Year] = SELECTEDVALUE ( Sale[Date].[Year] )
            )
        ),
        CALCULATE (
            DIVIDE ( CALCULATE ( SUM ( Sale[Sales] ) ), CALCULATE ( SUM ( Sale[Target] ) ) )
        ),
        ,
        DESC,
        DENSE
    )

    Big thanks to Zubair_Muhammad