Forum Discussion
Calculate Max Date by Employee Number
Hello - I need to create a filter to determine the max date by employee ID for a table which has the following:
| RVP | RDO | Location | DATE | Tech Name | Employee Number |
| RVP 1 | RDO 1 | Norfolk | 1/16/2021 | Doe, John | 149531 |
| RVP 1 | RDO 1 | Norfolk | 1/18/2021 | Doe, John | 149531 |
| RVP 1 | RDO 1 | Norfolk | 12/29/2020 | Doe, John | 149531 |
| RVP 1 | RDO 1 | Norfolk | 12/30/2020 | Doe, John | 149531 |
| RVP 1 | RDO 1 | Norfolk | 12/31/2020 | Doe, John | 149531 |
| RVP 1 | RDO 2 | VA Beach | 1/5/2021 | Morgan, Terry | 123456 |
| RVP 1 | RDO 2 | VA Beach | 1/6/2021 | Morgan, Terry | 123456 |
| RVP 1 | RDO 2 | VA Beach | 1/7/2021 | Morgan, Terry | 123456 |
| RVP 1 | RDO 2 | VA Beach | 1/8/2021 | Morgan, Terry | 123456 |
I want to return the max date by employee number. I tried the following:
Max Date = MAX(MAX('Table','Table'[DATE])) and MAXX(MAX('Table','Table'[DATE]))
but that returned the date.
Any help would be appreciated. Thanks!
ConnieMaldonado use this expression:
Max Date = CALCULATE ( MAX ( 'Table'[Date] ), ALLEXCEPT ( 'Table', 'Table'[Employee Number] ) )Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
5 Replies
- parry2k
Super User
ConnieMaldonado use this expression:
Max Date = CALCULATE ( MAX ( 'Table'[Date] ), ALLEXCEPT ( 'Table', 'Table'[Employee Number] ) )Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
- ConnieMaldonado
Responsive Resident
Thank you - one more question. I have a measure to calculate Total Hours for each employee and would like to include a filter so that I'm calculating the max date for all the records for the employee for which Total Hours > 0. I have a filter on the visual, so I'm not sure why that doesn't work. Can I add a filter to the ALLEXCEPT statement?
- parry2k
Super User
ConnieMaldonado if Total Hours is a column, make this change
Max Date = CALCULATE ( MAX ( 'Table'[Date] ), ALLEXCEPT ( 'Table', 'Table'[Employee Number] ) 'Table'[Total Hours] > 0 )Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
- ConnieMaldonado
Responsive Resident
Unfortunately, Total Hours is a measure. I tried the statement above, but of course Total Hours is not allowed in the expression. I've tried several different things to no avail.
- ConnieMaldonado
Responsive Resident
I got this to work. I was able to create a column for the hours and used your code above! Thanks! You're the best.
Max Date =
CALCULATE (
MAX ( 'Table'[Date] ),
ALLEXCEPT ( 'Table', 'Table'[Employee Number] ) ,
'Table'[Total Hours] > 0
)