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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
jfunderburk
Frequent Visitor

Sum Hours with a Group By date in a Column/Measure

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:

OrderEmployeeDateHours
1James6/16/20185
2James6/16/20185
3James6/16/20185
4James6/17/20186.2
5James6/17/20186.2
6James6/17/20186.2
7James6/17/20186.2
8James6/15/20182
9James6/15/20182
10James6/15/20182
11Sue6/1/20184
12Sue6/1/20184
13Sue6/1/20184
14Sue6/1/20184
15Sue6/3/20183
16Sue6/4/20182
17Sue6/5/20188
18Sue6/15/20184
19Sue6/15/20184
20Sue6/15/20184

 

Here is a table with what is returning in PowerBI and what I want it to show instead:

EmployeeOrdersHours (WRONG)Avg per Hour (WRONG)Hours (Wanted)Avg per Hour (WANTED)
James10045.82.18340611413.27.575758
Sue60411.463414634212.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

3 REPLIES 3
Anonymous
Not applicable

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.

EmployeeOrdersHours (WRONG)Avg per Hour (WRONG)Hours (Wanted)Avg per Hour (WANTED)
James1045.80.21834061113.20.757576
Sue10410.243902439210.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

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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