Forum Discussion

PiyushBQ's avatar
PiyushBQ
Helper I
3 years ago
Solved

Get Rolling Maximum

Hi,

 

I'm trying to get the maximum rolling value in a table, till each date.

 

Here's the table, with the desired output column:

 

DateProductValueDesired Output (Highest Value Till Date)
Jan-22A2020
Feb-22A2424
Apr-22A2824
Jun-22A1424
Jul-22A2024
Sep-22A3030
Nov-22A2930
Dec-22A3232
Feb-23A1832
Apr-23A1732
Jun-23A1632


When we add a date filter through a slicer, the dynamic max value should be recalculated like this (select date>= June 2022)
Or when we select another product, the max value should be recalculated according to the filtered view.

 

DateProductValueDesired Output (Highest Value Till Date)
Jun-22A1414
Jul-22A2020
Sep-22A3030
Nov-22A2930
Dec-22A3232
Feb-23A1832
Apr-23A1732
Jun-23A1632
 
I've written the following code but it's not recalculating the max value when applying the date filter through a slicer.
 
Dynamic MAX = CALCULATE(MAX('Table'[Value], KEEPFILTERS('Table'[Date] <= MAX('Table'[Date])), REMOVEFILTERS('Table'[Value]))
 
Any pointers?

Thank you in advance!
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi PiyushBQ ,

     

    Based on your logic described, the desired output in Apr-22 should be 28 instead of 24.

    I create the dynamic measure as

    Dynamic MAX = CALCULATE(MAX('Table'[Value]),FILTER(ALLSELECTED('Table'),[Product]=MAX('Table'[Product])&&[Date]<=MAX('Table'[Date])))

    The result changes when the slicer is filtered.

       

                                                                                                                                                             

    Best Regards,

    Stephen Tao

     

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

2 Replies

  • Alf94's avatar
    Alf94
    Solution Supplier

    Hello PiyushBQ,

     

    I think the following may do the trick:

     

    Highest value = 
        MAXX(
            WINDOW(
                1, ABS,
                0, REL,
                ORDERBY( 'Table'[Date], ASC )
            ),
            CALCULATE( SUM( 'Table'[Value] ) )
        )

     

    Let me know if this is ok.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi PiyushBQ ,

     

    Based on your logic described, the desired output in Apr-22 should be 28 instead of 24.

    I create the dynamic measure as

    Dynamic MAX = CALCULATE(MAX('Table'[Value]),FILTER(ALLSELECTED('Table'),[Product]=MAX('Table'[Product])&&[Date]<=MAX('Table'[Date])))

    The result changes when the slicer is filtered.

       

                                                                                                                                                             

    Best Regards,

    Stephen Tao

     

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