Forum Discussion
Getting help with this complicated DAX question
- 2 years ago
The LASTDATE filter will adjust the filter context to only return a single date. COUNTROWS then calculates the employee count for that date (month).
None of this though, seems to specify about returning the lastdate value in a specified month. How does this DAX function work for this use case? Thanks for your reply...
LASTDATE returns the latest date within whatever filter context is set, so if there is a slicer or a filter specifying a month, you get the last date in that month.
- YoungLearning2 years agoHelper III
I have tested it out and I kinda see how it works, on a visual level. But does DAX know that the last date of the month is e.g. 31st of December? How does using different date columns of different table affect the count, how does it know without using like Distinct Count or something?
- YoungLearning2 years agoHelper III
fyi when i did this just to test it out... why is it like this?
MeasureLast = LASTDATE(Date_X[Date])- TomMartens2 years agoSuper User
Hey YoungLearning ,
as AlexisOlson mentioned LASTDATE returns the last date of the filter context. The date hierarchy present in the table view is "contributing" to the filter context of the cell that shows the result of your LASTDATE measure. Each cell has a different filter context, for this reason the measure returns a different value in each cell. If you remove the day column from the table you will see that LASTDATE will return the last date of the month.
Regards,
Tom
- AlexisOlson2 years agoSuper User
It's referencing a date table which should have all dates you need, so it's just a max over the dates in the date context.