cancel
Showing results for
Did you mean:
Highlighted
Frequent Visitor

## DAX formula to calculate days worked out of possible days

Simplifying things, I have a report using DirectQuery with 2 tables: Date and EmployeeTimesheet.

Date columns: DayeKey, Date, Year, Month, DayOfWeek, isWeekday

EmployeeTimesheet columns: EmployeeID, DateKey, TaskID, MinutesWorked

Example:

What I'm trying to calculate (and graph) is the number of days out of all available weekdays where the employee worked at least 60 mins.  So there are 23 weekdays in January (isWeekday=1).  Therefore, in January, EmployeeA worked 2 days out of 23, or 8%.

I've tried defining a measure as below, and using it as a filter (Daily Time Total > 60), but it aggregates the hours to the Employee level and doesn't filter properly.

Daily Time Total =
CALCULATE(
SUM('EmployeeTimesheet'[MinutesWorked]),
ALLSELECTED('EmployeeTimesheet'[DateKey])
)

1 ACCEPTED SOLUTION

Accepted Solutions
Super Contributor

## Re: DAX formula to calculate days worked out of possible days

Hi @cmorrow

Please check WorkCount measure in attached file.Link the two tables with DateKey column.

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
4 REPLIES 4
Super User

## Re: DAX formula to calculate days worked out of possible days

Are you looking for something like NETWORKDAYS?

https://community.powerbi.com/t5/Quick-Measures-Gallery/Net-Work-Days/m-p/367362

### I have book! Learn Power BI from Packt

Proud to be a Datanaut!

Frequent Visitor

## Re: DAX formula to calculate days worked out of possible days

No, I don't think so.  When I try to translate that to my needs, it doesn't work.  For example, if I were to do this in SQL:

select EmployeeID, count(DateKey) from (
select EmployeeID, f.DateKey
from EmployeeTimesheet f
join Date d on d.DateKey = f.DateKey
and f.DateKey between 20190101 and 20190131
and IsWeekday = 1
group by EmployeeID, f.DateKey
having sum(MinutesWorked) > 60
) a
group by EmployeeID

Just not sure if there's a way to do the same thing in DAX.

Super Contributor

## Re: DAX formula to calculate days worked out of possible days

Hi @cmorrow

Please check WorkCount measure in attached file.Link the two tables with DateKey column.

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Frequent Visitor

## Re: DAX formula to calculate days worked out of possible days

Cherie -

You are my hero.  That works perfectly.  Thank you!

Announcements

#### Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

#### Power Platform Summit North America

Register by September 5 to save \$200

#### Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

#### Watch Sessions On Demand!

Continue your learning in our online communities.

Top Kudoed Authors
Users Online
Currently online: 122 members 1,727 guests
Recent signins: