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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

DAX Show Value based on latest date with multiple filters

I'm fairly novice in DAX and need help with the following forumla:

What i need is a measure that will display the latest (most recent date) hours for a specific unit and type:

If i wanted Unit 1 Type A, i would want it to display 1200 (this is the hours from the most recent entry)

MAX function will not work as the hours can be higher on ealier dates so i need the latest hours from the date/time

 

Date/TimeUnitTypeHours
01/01/2020 1:00Unit 1A1000
01/02/2020 8:00Unit 2B500
01/10/2020 10:00Unit 1A1100
01/11/2020 8:00Unit 2A600
01/12/2020 8:00Unit 1A1200
2 REPLIES 2
Anonymous
Not applicable

HI @Anonymous,

You can use the following measure formula to get lastest hours based on the current unit and type group:

 

Lastest Hour =
VAR filtered =
    CALCULATETABLE (
        t3,
        ALLSELECTED ( t3 ),
        VALUES ( T3[Unit] ),
        VALUES ( T3[Type] )
    )
VAR _max =
    MAXX ( filtered, [Date/Time] )
RETURN
    MAXX ( FILTER ( filtered, [Date/Time] = _max ), [Hours] )

 

Regards,

Xiaoxin Sheng

amitchandak
Super User
Super User

@Anonymous 

Try

 

VAR __id = MAX ( 'Table'[id] )
VAR __Type = MAX ( 'Table'[Type] )

VAR __date = CALCULATE ( MAX( 'Table'[date] ), ALLSELECTED ( 'Table' ),  'Table'[id] = __id,'Table'[Type] = __Type  ) 
RETURN CALCULATE ( MAX ( 'Table'[value] ), VALUES ( 'Table'[id] ), 'Table'[id] = __id,'Table'[Type] = __Type , 'Table'[date] = __date )

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Kudoed Authors