cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
abhishekmor
Frequent Visitor

DAX to calculate Total Hours based on different dates

I am working on a timesheet report and facing one issue.

As of now, to calculate Available Hours of employees we are calculating based on

Count of Employees selected * Count of Weeks Selected * 40

 

abhishekmor_0-1621105830714.png

 

abhishekmor_1-1621105830723.png

 

 

abhishekmor_2-1621105830728.png

 

 

Now manager requesting to calculate Available hours based on Employee’s joining date.

Employee               JoinDate

E1                           05/02/2021

E2                           25/01/2021

E3                           15/03/2020

If I am selecting 3 employees from Team Slicer and first 3 months of 2021, so for E1 and E2 employees it should calculate from their joining date and not from the week selected and for E3 it should calculate from first week selected as it is greater than joining date.

1 REPLY 1
amitchandak
Super User
Super User

@abhishekmor , Try like

 


new measure =
var _max = maxx(allselected('Date'), Date[Date])
var _min1 = maxx(allselected('Date'), Date[Date])
var _min = max(_min1, min(employee[joining date])
return
sumx(values(Employee[Employee]), calculate(datediff(_min1, _max,week))*40)

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin

Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Power BI October Update 2021.jpg

Power BI Release

Click here to read more about the October 2021 Release!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Teds Dev Camp Oct. 2021 768x460.jpg

Power BI Dev Camp - October 28th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!