Forum Discussion

Piyush_Ghungrud's avatar
3 years ago
Solved

Ranking Months Based on Date Slicer selected date.

Hi Community, 

I have been wondering if we can create a Ranking Till Dates selected in the Slicer. 
Here I have a data which has product, launch date, month and sales.

ProductLaunch DateMonthSales
AAug-20Sep-2010
AAug-20Oct-208
AAug-20Dec-205
BMay-20Aug-204
BMay-20Sep-209
BMay-20Oct-206
CJan-21Feb-218
CJan-21Mar-215
CJan-21May-216

 

I was thinking if it is possible to Create a Dynamic Rank , based on the order of months, given the date selected.

 Date SelectedDec-20  
     
Product  Sales  Launch Date  Month  RANK  
A10Aug-20Sep-201
A8Aug-20Oct-202
A0Aug-20Nov-203
A5Aug-20Dec-204
B0May-20Jun-201
B0May-20Jul-202
B4May-20Aug-203
B9May-20Sep-204
B6May-20Oct-205

 

if, the data between launch and month is not there, then it should take the date in order and also rank it.


Thank you 

 

  • Anonymous's avatar
    Anonymous
    3 years ago

    hello Piyush_Ghungrud ,
    please use this new measure:

    Index expected result: = 
    VAR _startdate =[Begin]
    VAR _monthyearbyproducttable =
        CALCULATETABLE (
            SUMMARIZECOLUMNS ( 'Table'[Year-Month], 'Table'[Sort] ),
            FILTER ( ALL('Table'), 'Table'[Date] >= _startdate )
        )
    RETURN
        IF (
            NOT ISBLANK ( [Sales Measure] )
                && HASONEVALUE ( 'Table'[Year-Month] ),
            COUNTROWS (
                WINDOW (
                    1,
                    ABS,
                    0,
                    REL,
                    _monthyearbyproducttable,
                    
                    ORDERBY ( 'Table'[Sort], ASC )
                )
            )
        )

     

    example 1:

     

    example 2:

     

    here is the powerbi file: https://1drv.ms/u/s!Ag9tIyk2ofNRjmhuYW0Ig0PdVG-9?e=pREtpE

    if it solved it please accept this as a solution and thank you Jihwan_Kim for the help


17 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hello Piyush_Ghungrud i didnt quiet understand the condition of ranking, if you select december 20 on what basis should it rank?

    • Piyush_Ghungrud's avatar
      Piyush_Ghungrud
      Icon for Helper I rankHelper I

      Thank you Anonymous for reaching me,

      I want to rank months from the launch date of the product till the selected date.
      As you can see, the selected month is Dec 20, till Dec 20 whatever product has launched has been displayed and ranking given to the months(Please note: Between Launch Date and Month, there could be missing Months data, but it should fill the missing months and rank those months also).
      Please, let me know for further information.
      Thank you 🙂

      • Piyush_Ghungrud's avatar
        Piyush_Ghungrud
        Icon for Helper I rankHelper I

        Hi Anonymous ,

        In addition to this, The different products can have the same ranks, as the ranking is based on months and the distinct product is selected.