Forum Discussion

rampsaladi's avatar
rampsaladi
Frequent Visitor
8 years ago

Dynamic Rank per Product in Time Period

Hi 

 

I need to be help create a Rank column. I need to be able to generate the rank in the context of the Time Period for the Products based on the Amount and This rank will be in the context of the Market where the market acts as a slicer. I added the sample data and the rank. The DAX I created always gives me a rank 1.

 

MarketsProductTime PeriodAmtRank
NorthALast 52 Weeks11
NorthBLast 52 Weeks22
NorthCLast 52 Weeks33
NorthDLast 52 Weeks44
NorthELast 52 Weeks55
NorthFLast 52 Weeks66
NorthALast 13 Week115
NorthBLast 13 Week124
NorthCLast 13 Week46
NorthDLast 13 Week3242
NorthELast 13 Week323
NorthFLast 13 Week34341
NorthALast 26 Weeks106
NorthBLast 26 Weeks344
NorthCLast 26 Weeks135
NorthDLast 26 Weeks4324321
NorthELast 26 Weeks34232
NorthFLast 26 Weeks1243
NorthALast 4 Weeks15
NorthBLast 4 Weeks42
NorthCLast 4 Weeks71
NorthDLast 4 Weeks24
NorthELast 4 Weeks33
NorthFLast 4 Weeks06

 

Any Help is appreciated.

11 Replies

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

    So, are you OK if this is a measure? I have had far more luck with RANKX as a measure versus as a column. You could create two measures:

     

    MySum = SUM(Table[Amt])
    
    MyRank = RANKX(ALL(Table),[MySum])

     

    You can create a column like this:

     

    Column = RANKX(aRanks,[Amt])

    But it won't be grouped like you want. Here is one of the better articles explaining RANKX:

     

    https://www.wiseowl.co.uk/blog/s2469/rankx-function.htm 

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

      rampsaladi

       

      GIve this MEASURE a shot as well

       

      RANK =
      RANKX (
          FILTER (
              ALLSELECTED ( Table1 ),
              Table1[Time Period] = SELECTEDVALUE ( Table1[Time Period] )
          ),
          CALCULATE ( SUM ( Table1[Amt] ) ),
          ,
          DESC,
          DENSE
      )
      
      • Zubair_Muhammad's avatar
        Zubair_Muhammad
        Icon for Community Champion rankCommunity Champion

        rampsaladi

         

        Infact this one should give the proper results with slicers

         

        RANK =
        RANKX (
            CALCULATETABLE (
                VALUES ( Table1[Product] ),
                FILTER (
                    ALLSELECTED ( Table1 ),
                    Table1[Time Period] = SELECTEDVALUE ( Table1[Time Period] )
                )
            ),
            CALCULATE ( SUM ( Table1[Amt] ) ),
            ,
            DESC,
            DENSE
        )
        
  • Anonymous's avatar
    Anonymous
    Not applicable

    Hello All,,

    My requirement is to give rank values to last 12 months dynamically And we follow June of every month as our finnacial year. Can anyone please help with the rank function measure to create calculated column

    It would be really helpfull thanks