Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
PiyushBQ
Helper I
Helper I

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!
1 ACCEPTED SOLUTION
v-stephen-msft
Community Support
Community Support

Hi @PiyushBQ ,

 

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

16.png

I create the dynamic measure as

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

vstephenmsft_0-1681809362177.png

The result changes when the slicer is filtered.

vstephenmsft_1-1681809375330.png

   

                                                                                                                                                         

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.           

View solution in original post

2 REPLIES 2
v-stephen-msft
Community Support
Community Support

Hi @PiyushBQ ,

 

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

16.png

I create the dynamic measure as

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

vstephenmsft_0-1681809362177.png

The result changes when the slicer is filtered.

vstephenmsft_1-1681809375330.png

   

                                                                                                                                                         

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.           

Alf94
Super User
Super User

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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.