cancel
Showing results 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.

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:

 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

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

Frequent Visitor

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
Employee

@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.

Announcements

#### 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

#### Power BI Monthly Update - April 2024

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

#### Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors