To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
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/Time | Unit | Type | Hours |
01/01/2020 1:00 | Unit 1 | A | 1000 |
01/02/2020 8:00 | Unit 2 | B | 500 |
01/10/2020 10:00 | Unit 1 | A | 1100 |
01/11/2020 8:00 | Unit 2 | A | 600 |
01/12/2020 8:00 | Unit 1 | A | 1200 |
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
@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 )