Forum Discussion
Distinct count across multiple columns but looking for the latest date for the record
Hey Community,
I have a data set that contains a list of stores and all of the health permits associated with it. The data also contains an issue start date and end date.
I want to count the a distinct number of stores per certificate with latest start date.
Example:
Store Code: ABC123 Certificate Type: ServSafe Certificate Issue Start Date: 2/23/2024 Issue End Date: 2/23/2026
Store Code: ABC123 Certificate Type: ServSafe Helper Certificate Issue Start Date: 2/23/2024 Issue End Date: 2/23/2026
Store Code: ABC123 Certificate Type: ServSafe Certificate Issue Start Date: 2/23/2021 Issue End Date: 2/23/2024
Count should be 1 for ServSafe Certificate and 1 for ServSafe Helper Certificate.
Any guidance will be appreciated.
2 Replies
- lbendlin
Super User
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information or anything not related to the issue or question.
If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216
Please show the expected outcome based on the sample data you provided.
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523 - qqqqqwwwweeerrr
Solution Sage
Hi Anthony_A
i guess this measure should work for you.
get_count =VAR MaxDate_ = CALCULATE(MAX(Sheet3[Start Date]),ALLEXCEPT(Sheet3,Sheet3[Certificate Type]))RETURN CALCULATE(DISTINCTCOUNT(Sheet3[Store ID]),Sheet3[Start Date]=MaxDate_)Did I answer your question? if not please provide more details about the problem. Mark my post as a solution! Appreciate your Kudos!!
Check for more intersing solution here: https://www.youtube.com/@letssolveproblem
RegardsRegards