Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Help - Rank a dynamic column? I need the rank column for Lookup function.

I have a date column. I created an index column which starts from 1.

 For example:

Items  Rank

a             1

b            2

c            3

d           4

 

When I apply the filter- It shows:

Item   Rank

b          2

c          3

 

But I need something like this -

Item Rank

b         1

c          2

 

And I need to use that Rank column as a Lookup column to find other values.

10 Replies

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

    Hi Anonymous 

    try smth like this

    Measure = rankx(ALLSELECTED(Tbl_Rank);CALCULATE(FIRSTNONBLANK(Tbl_Rank[Items];Tbl_Rank[Items]));;ASC)
    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi,

      Thanks for your reply!

      But the code did not help.

      I'm getting 1 for every row in the table.

      It does not sort the remaining rows on the basics of start dates after applying the filters.

       

      Thanks

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

        Hi Anonymous 

        It's strange because it works great with any filters applied

        could you show all youe data model or *.pbix?

  • Anonymous's avatar
    Anonymous
    Not applicable

    hi Anonymous ,

     

    By using your data I write rank function please check two Measures and I shared two outputs also.

    Please watch it.

     

    --by using ALL function
    Rank = RANKX(ALL('Table'),[Sum],,DESC,Skip)
    -- by using ALLSELECTED function
    Rank = RANKX(ALLSELECTED('Table'),[Sum],,DESC,Skip)

     

    regards,

    Naveen

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks for your reply.


      What is the sum measure?

      • Anonymous's avatar
        Anonymous
        Not applicable

        hi Anonymous ,

         

        Sum = SUM(Table[Number])

        regards,

        Naveen