The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi all,
I am trying to create a column/measure that takes a count of orders and divides it by the hours worked by an employee on a given day to get the average order per hour. In the query, I am joining the hours per day on each order, so I think PowerBI is summing those up when I need it to group by date when actually manipulating the data. I cannot aggregate and group by in the query or I lose the ability to export detailed information in PowerBI on each order.
Here is a fake data set of the relevant columns:
Order | Employee | Date | Hours |
1 | James | 6/16/2018 | 5 |
2 | James | 6/16/2018 | 5 |
3 | James | 6/16/2018 | 5 |
4 | James | 6/17/2018 | 6.2 |
5 | James | 6/17/2018 | 6.2 |
6 | James | 6/17/2018 | 6.2 |
7 | James | 6/17/2018 | 6.2 |
8 | James | 6/15/2018 | 2 |
9 | James | 6/15/2018 | 2 |
10 | James | 6/15/2018 | 2 |
11 | Sue | 6/1/2018 | 4 |
12 | Sue | 6/1/2018 | 4 |
13 | Sue | 6/1/2018 | 4 |
14 | Sue | 6/1/2018 | 4 |
15 | Sue | 6/3/2018 | 3 |
16 | Sue | 6/4/2018 | 2 |
17 | Sue | 6/5/2018 | 8 |
18 | Sue | 6/15/2018 | 4 |
19 | Sue | 6/15/2018 | 4 |
20 | Sue | 6/15/2018 | 4 |
Here is a table with what is returning in PowerBI and what I want it to show instead:
Employee | Orders | Hours (WRONG) | Avg per Hour (WRONG) | Hours (Wanted) | Avg per Hour (WANTED) |
James | 100 | 45.8 | 2.183406114 | 13.2 | 7.575758 |
Sue | 60 | 41 | 1.463414634 | 21 | 2.857143 |
Here is the DAX for my column: Average Orders Per Hour = DIVIDE(count(Query1[orders]),sum(Query1[hoursworked]))
Appreciate any and all help!
-Josh
can you explain how did you get orders 100, 60 from the above table? what formula used for that?
Thanks
Raj
I just threw some numbers in there. Here is a table that matches the quantities in the raw data.
Employee | Orders | Hours (WRONG) | Avg per Hour (WRONG) | Hours (Wanted) | Avg per Hour (WANTED) |
James | 10 | 45.8 | 0.218340611 | 13.2 | 0.757576 |
Sue | 10 | 41 | 0.243902439 | 21 | 0.47619 |
@jfunderburk,
How do you get hours(13.2, 21) based on the sample data you post in the original post? When you create a measure using the DAX you post, you should get expected result.
Regards,
Lydia