Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
hi PowerBI experts,
i have a data file with the executed tasks of our employees and the date of these tasks. I want to calculate the number of unique days in a certain period in which tasks are executed.
I have the following data table:
Task ID | Empl. ID | Date |
1 | 10 | 04-01-2021 |
2 | 10 | 04-01-2021 |
1 | 10 | 13-01-2021 |
3 | 10 | 15-01-2021 |
1 | 10 | 18-01-2021 |
5 | 20 | 11-01-2021 |
2 | 20 | 18-01-2021 |
7 | 20 | 18-01-2021 |
1 | 10 | 01-02-2021 |
5 | 10 | 08-02-2021 |
9 | 10 | 08-02-2021 |
9 | 20 | 08-02-2021 |
1 | 20 | 11-02-2021 |
1 | 20 | 12-02-2021 |
2 | 20 | 12-02-2021 |
I want the following outcome:
Company level:
Month | Unique days tasks executed in selected period |
Jan | 5 |
Feb | 4 |
Employee level:
Employee ID (jan and feb) | Unique days task executed in selected period (jan and feb) |
10 | 6 |
20 | 5 |
So if a employee performed multiple tasks on 1 day, it has to be calculated as 1 unique day (fe empl. ID 10 on 04-01-2021), and if 2 employees performed tasks on the same day, on general level it has to be calculated as 1 unique day, but on employee level it has to be calculated as 2 (fe 08-02-2021, where empl. ID 10 and 20 both performed tasks).
Many thanks for your help!
Regards,
Frank
Solved! Go to Solution.
Hi, @frankhofmans
To count only the working days, please create a calculated column as below
Column = IF(WEEKDAY('Data Table'[Date],2)IN{1,2,3,4,5}, 1, blank())
And then add a filter condition to your original measure as follows:
Unique days tasks executed in selected period =
CALCULATE (
DISTINCTCOUNT ( 'Data Table'[Date] ),
FILTER ( 'Data Table', 'Data Table'[Column] = 1 )
)
Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi jdbuchanan71,
This works, but is there a way to count only the working days? I added a column (if date = weekday, 1, blank()) and did the distinctcount (on the new column), but i still get weekend results (strange, cause in the new colums, there aren't any weekend dates).
Thanks!
Hi, @frankhofmans
To count only the working days, please create a calculated column as below
Column = IF(WEEKDAY('Data Table'[Date],2)IN{1,2,3,4,5}, 1, blank())
And then add a filter condition to your original measure as follows:
Unique days tasks executed in selected period =
CALCULATE (
DISTINCTCOUNT ( 'Data Table'[Date] ),
FILTER ( 'Data Table', 'Data Table'[Column] = 1 )
)
Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Give this a try.
Unique days tasks executed in selected period = DISTINCTCOUNT ( 'data table'[Date] )
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
99 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
102 | |
87 | |
64 |