cancel
Showing results for
Did you mean:
Helper III

## Count the number of days in a certain period

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).

Regards,

Frank

1 ACCEPTED SOLUTION
Community Support

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.

3 REPLIES 3
Helper III

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!

Community Support

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.

Super User II

Give this a try.

Unique days tasks executed in selected period = DISTINCTCOUNT ( 'data table'[Date] )

Announcements