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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
vpatel55
Kudo Commander
Kudo Commander

Lookup DateTime based on the MAX of another column

I would like a DAX formula that would return the DateTime corresponding to the MAX of Price on this list.

 

27 is the largest Price, so the answer should be either 17/12/2020 17:00 or 18/12/2020 18:00, I don't mind which one:

 

p1.png

 

Here is the formula that I am currently using:

 

 

DateTime of most expensive product =
CALCULATE (
    FIRSTNONBLANK ( Data[DateTime], 1 ),
    FILTER ( Data, MAX ( Data[Price] ) )
)

 

 

The result appearing is 10:00. This is not the required result. I can see what its doing, its returning the first row that is not blank. But I don't know which other "wrapper" I can use? I tried using LOOKUPVALUE, but as I have a duplicate this does not work.

 

Any help would be appreciated. Here is the sample file:

 

https://www.dropbox.com/s/a5001h3htve47lf/Sample%20file.pbix?dl=0

 

1 ACCEPTED SOLUTION
ChrisMendoza
Resident Rockstar
Resident Rockstar

@vpatel55 - try the following:

Measure = 
VAR __maxPrice = CALCULATE(MAX('Table'[Price]),ALL('Table'))
RETURN 
    CALCULATE(
        MAX('Table'[DateTime]),
        'Table'[Price] = __maxPrice
    )

image.png






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



View solution in original post

2 REPLIES 2
ChrisMendoza
Resident Rockstar
Resident Rockstar

@vpatel55 - try the following:

Measure = 
VAR __maxPrice = CALCULATE(MAX('Table'[Price]),ALL('Table'))
RETURN 
    CALCULATE(
        MAX('Table'[DateTime]),
        'Table'[Price] = __maxPrice
    )

image.png






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



Huge Kudos @ChrisMendoza , super user indeed! 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Top Solution Authors