Forum Discussion
Pulling most recent value
Hi all,
For some reason I am struggling to figure out how to pull the last value, the column is a calculated column (each row contains a 0 or 1 the field has been set to average). When I put the data in a table visual....
| Date | Product Sales |
| 1/1/2022 | 19.00% |
| 1/6/2022 | 22.00% |
I was playing around with the following to try and get the 22.00%....obviously not working for me
% Product Sales =
CALCULATE(
SUM(Table[Product Sales]),
FILTER(TABLE, TABLE[Product Sales] = LASTDATE(ALLSELECTED(TABLE[Date]))))
Any help would be appreciated
- Anonymous4 years ago
The following worked for me
Measure =VAR Max_Date = MAX(Table[Date])VAR Latest_MS = CALCULATE([Measure2],Table[Date]=Max_Date)Return Latest_MSSource: Get Most recent/Max Date value in PowerBI using DAX | MiTutorials - YouTube
5 Replies
- amitchandakSuper User
Anonymous , Try like
lastnonblankvalue(TABLE[Date],SUM(Table[Product Sales]))
- AnonymousNot applicable
amitchandak Thank you for your response.
Unfortunately it did not work, it ended up returning the latest date when I put the measure into a card.- AnonymousNot applicable
The following worked for me
Measure =VAR Max_Date = MAX(Table[Date])VAR Latest_MS = CALCULATE([Measure2],Table[Date]=Max_Date)Return Latest_MSSource: Get Most recent/Max Date value in PowerBI using DAX | MiTutorials - YouTube
- SaapResolver III
Hi Anonymous
Maybe try to use this measure:% product sales =var MaxDate = CALCULATE(MAX('Table'[Date]), ALL('Table'))returnCALCULATE(MAX('Table'[Product Sales]), FILTER('Table','Table'[Date]=MaxDate))
It display this value when put into card visual.- danextianSuper User
Hi Saap ,
Try this measure below. Change the table and column names accordingly
Value of the latest date = VAR __MAX_DATE = CALCULATE ( MAX ( Dates[Date] ), ALLSELECTED ( Dates ) ) //ALLSELECTED for the max date in the current filter context, ALL for the max date in the Dates table regardless of the filters applied RETURN CALCULATE ( [Sum of Values], Dates[Date] = __MAX_DATE )sample result -