Forum Discussion
Create DAX code to Calculate average time on given data set
I have a table called "Employee", It has following header.
User , Employee ID, Day, Logged Hours, Productive Hours, Manager, Senior Manager, Director
It has more than 6 months data and user count is more than 5K.
I want to calculate weekly/Monthly Average Productive/Logged hours for each Manager, Director etc.
Condition is that user can work for maximum seven days however in calculation their work day will be consider 5.
e.g. one user worked Mon to Thu then worked on sat and sun so average time should be sum of all from Mon to Sun divided by 5
Could you please help me to write the dax code. Thanks
3 Replies
- Jihwan_KimSuper User
Hi,
I am not sure how your datamodel looks like, but I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file.
I hope the below can provide some ideas on how to create a solution for your datamodel.
- GudduKumarFrequent Visitor
this is not how I'm looking for.
I have attached the data and expected result, could you please help me on that way.
user can work for 5 days or more in a week but in average calculation denominator should be 5
- GudduKumarFrequent Visitor
Thanks Jihwan,
However this is not something I'm looking for.
I have very simple ask. I have data as per below
User Day Sr. Manager Employee ID Manager Logged Hours Productive Hours Aamir 10 Jul 2023 Ramesh 108398 Dinesh 2.64 0.59 Aamir 11 Jul 2023 Ramesh 108398 Dinesh 12.7 4.69 Aamir 12 Jul 2023 Ramesh 108398 Dinesh 8.55 4.14 Aamir 13 Jul 2023 Ramesh 108398 Dinesh 4.89 3.76 Aamir 14 Jul 2023 Ramesh 108398 Dinesh 15.24 9.04 Aamir 15 Jul 2023 Ramesh 108398 Dinesh 10.36 8.6 Aamir 16 Jul 2023 Ramesh 108398 Dinesh 9.82 8.51 Aamir 17 Jul 2023 Ramesh 108398 Dinesh 11.96 4.33 Adithya 10 Jul 2023 Aman 108399 Rahul 10.91 5.38 Adithya 11 Jul 2023 Aman 108399 Rahul 7.65 3.82 Adithya 12 Jul 2023 Aman 108399 Rahul 10.82 6.78 Adithya 13 Jul 2023 Aman 108399 Rahul 8.8 3.97 Adithya 14 Jul 2023 Aman 108399 Rahul 3.18 2.35 Adithya 15 Jul 2023 Aman 108399 Rahul 1.75 1.52 Adithya 16 Jul 2023 Aman 108399 Rahul 0.13 0.09 Adithya 17 Jul 2023 Aman 108399 Rahul 5.94 2 I have data for more than 5k Employees,
My Simple request is that I want to see weekly/ Monthly Average Productive Hours For Each Manager/Sr Manager, only condition while calculating average is that Work day would be 5, even if employee has worked for 7 days.
e.g. Mon: 6, Tue: 7, wed: 5, Thu:8, Sat:9, Sun:10
Avg. Hrs= Sum(6+7+5+8+9+10)/5
I need this in DAX code so that I can plot it for everyone.
Thanks