Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
cmorrow
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:

EmployeeA, 20190101, Task1, 15

EmployeeA, 20190102, Task1, 15

EmployeeA, 20190102, Task2, 60

EmployeeA, 20190103, Task2, 90

 

 

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

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.

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

Are you looking for something like NETWORKDAYS?

 

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



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

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.

 

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.

Cherie - 

 

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

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

August Carousel

Fabric Community Update - August 2024

Find out what's new and trending in the Fabric Community.