Forum Discussion

LuisLOCapelari's avatar
3 years ago
Solved

Rank filtered date

I need help making a table or column that works similarly to RANKX, which indicates the order of dates in a table of dates, but that rank is reset according to the date selected in a slicer. For exa...
  • v-yueyunzh-msft's avatar
    v-yueyunzh-msft
    3 years ago

    Hi , LuisLOCapelari 

    Thanks for your quick response and your sharing sample pbix file to me!

    For your need , you want to add the dynamic rank in the x-axis along with the Quarter and Month.

    Here are the steps you can refer to :
    (1)First , we also need to create a dimension table using the "Numetric range":

    (2)We can create two measures like this:

    Measure = 
     var _t=SELECTCOLUMNS( ALLSELECTED('Calendar') , "Date" , [Date])
     var _cur_date =  MAX('Calendar'[Date])
     return
     if(_cur_date in _t , RANKX( ALLSELECTED('Calendar') , CALCULATE(MAX('Calendar'[Date])) , ,ASC,Dense), BLANK())
    
    Measure 2 = var _t=ADDCOLUMNS( ALLSELECTED('Calendar') , "measure_rank" , [Measure],"value", CALCULATE(SUM('Sales'[Value])))
    var _xaxis = [Parameter Value]
    var _dates =  VALUES('Calendar'[Date])
    var _t2 = FILTER(_t , [Date] in _dates)
    return
    IF( ISINSCOPE('Parameter'[Parameter]),MAXX(FILTER(_t2 , [measure_rank] = _xaxis) , [value]) , SUM('Sales'[Value]))

     

    (3)Then we can put the fields on the visual and we can get the result as follows:

     

    Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

     

    Best Regards,

    Aniya Zhang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly