Forum Discussion
Get Most Recent Date and Amount
Hello,
I am trying to write a DAX measure that will give me the most recent date and the corresponding values for that date from a data set below:
| Date | Name | Amount |
| 06/09/2021 | An Other | 5899 |
| 09/11/2021 | An Other | 178 |
| 15/01/2021 | Jane Doe | 800 |
| 30/07/2021 | Jane Doe | 6400 |
| 22/02/2021 | John Smith | 66 |
| 23/05/2021 | John Smith | 2000 |
I have the following measure:
| Max Date | Name | Amount |
| 09/11/2021 | An Other | 6077 |
| 30/07/2021 | Jane Doe | 7200 |
| 23/05/2021 | John Smith | 2066 |
How do I write the measure to get the distinct values for the most recent dates i.e.
| Max Date | Name | Amount |
| 09/11/2021 | An Other | 178 |
| 30/07/2021 | Jane Doe | 6400 |
| 23/05/2021 | John Smith | 2000 |
Thank you.
Mirithu , try a measure like
count Measure =
VAR __id = MAX ('Table'[Name] )
VAR __date = CALCULATE ( MAX('Table'[DAte] ), ALLSELECTED ('Table' ), 'Table'[Name] = __id )
CALCULATE ( sum ('Table'[Amount] ), VALUES ('Table'[Name] ),'Table'[Name] = __id,'Table'[DAte] = __date )
2 Replies
- amitchandak
Super User
Mirithu , try a measure like
count Measure =
VAR __id = MAX ('Table'[Name] )
VAR __date = CALCULATE ( MAX('Table'[DAte] ), ALLSELECTED ('Table' ), 'Table'[Name] = __id )
CALCULATE ( sum ('Table'[Amount] ), VALUES ('Table'[Name] ),'Table'[Name] = __id,'Table'[DAte] = __date ) - Mirithu
Helper II
Works perfectly! Thank you.