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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
        )
    )

Regards
Zubair

Please try my custom visuals

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?


Regards
Zubair

Please try my custom visuals

Udklip.PNG

HI @BiBra

 

Replace

 

FIRSTNONBLANK ( 'inStock'[DateFirstSaved], 1 )

 

With

 

Values('inStock'[DateFirstSaved])

or

 

MAX('inStock'[DateFirstSaved])

Regards
Zubair

Please try my custom visuals

Udklip.PNG

No errors in the code now. However it cannot display

Hi @BiBra,

 

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

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

@BiBra

 

or replace the comma with

 

FIRSTNONBLANK ( 'inStock'[DateFirstSaved]; 1 )

Regards
Zubair

Please try my custom visuals

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.