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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
BiBra
Helper III
Helper III

Retrieve the max value

Hello

I want to retrieve two things: value at recent date, and the date, where the value was at the highest. I have achieved the first by a measure. However, when I try to retrieve the date with max value, I am unable to do so.  The following is the code that works: 

 

Value at recent date = 
CALCULATE(
SUM('inStock'[Value]);
FILTER('inStock';'inStock'[DateFirstSaved] = MAX('inStock'[DateFirstSaved])))

 

The following is what does not work:

 

 

Max value = 
CALCULATE(
SUM('inStock'[Value]);
FILTER('inStock';'inStock'[DateFirstSaved] = MAX('inStock'[Value])))

 

Can anyone help me achieve this?

 

 

8 REPLIES 8
Zubair_Muhammad
Community Champion
Community Champion

@BiBra

 

Please try this

 

Max value =
VAR myvalue = [Value at recent date]
RETURN
    CALCULATE (
        FIRSTNONBLANK ( 'inStock'[DateFirstSaved], 1 ),
        FILTER (
            ALLSELECTED ( 'inStock'[DateFirstSaved] ),
            CALCULATE ( SUM ( inStock[Value] ) ) = myvalue
        )
    )

I am trying it out right now. However I experienced, that it will not accept 1 in FIRSTNONBLANK.

@BiBra

 

It should. Even you could out 0, TRUE()

 

Could you share the screen shot?

Udklip.PNG

HI @BiBra

 

Replace

 

FIRSTNONBLANK ( 'inStock'[DateFirstSaved], 1 )

 

With

 

Values('inStock'[DateFirstSaved])

or

 

MAX('inStock'[DateFirstSaved])

Udklip.PNG

No errors in the code now. However it cannot display

Anonymous
Not applicable

Hi @BiBra,

 

Please share some sample data and pbix file for further test.

 

Regards,

Xiaoxin Sheng

@BiBra

 

or replace the comma with

 

FIRSTNONBLANK ( 'inStock'[DateFirstSaved]; 1 )

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors