Reply
Power_It_Up
Helper I
Helper I
Partially syndicated - Outbound

Grouping daily hours by employee/month

Hello.  I have been on this problem for nearly two days.  I've searched on this forum and others for an answer.  Have tried all manner of calcs using SUMX, CALCULATE, GROUP, EVALUATE, SUMMARIZE, FILTER the list goes on.

 

The below table is a screenshot for Employee A (we have hundreds) and how many hours a day they work.  For this, I just pulled in the Hours field and chose DON'T SUMMARIZE.  This is correct:-

 

Power_It_Up_0-1722612869514.png

 

Now, do you think I can make those hours add up correctly for January (should be 146.74, Mon to Fri, 23 days @ 6.38):-

Using SUM, AVERAGE..... nothing.

 

Power_It_Up_1-1722613025817.png    Power_It_Up_2-1722613062280.png

 

The data source is a custom CTE sql joining two tables, hence why I tried the above DAX options.

 

Have tried using a Calendar Table, but nothing.

 

Many thanks for your help in advance. 🙂

 

 

 

3 ACCEPTED SOLUTIONS
Idrissshatila
Super User
Super User

Syndicated - Outbound

Hello @Power_It_Up ,

 

what if you extracted the month from the date and show the sum of hours by month, wouldn't this work ?

add a calculated column to get the month:

month name = format( datecolumn,"MMMM")



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




View solution in original post

LeandroDeodato
Resolver II
Resolver II

Syndicated - Outbound

i think you need convert you hours column in seconds, than sum, and convert again in hours. 

View solution in original post

v-yohua-msft
Community Support
Community Support

Syndicated - Outbound

Hi, @Power_It_Up 

Based on your information, I create a sample table:

vyohuamsft_0-1722825136751.png

 

Then create a new measure and try the following dax:

TotalHours = 
CALCULATE(
    SUM('Table'[Hours]),
    FILTER(
        'Table',
        'Table'[Attend Date] >= DATE(2024, 1, 1) &&
        'Table'[Attend Date] <= DATE(2024, 1, 31) &&
        WEEKDAY('Table'[Attend Date], 2) <= 5
    )
)

Here is my preview:

vyohuamsft_1-1722825214327.png

 

The reason why the January data is different from your 146.74 is because I see that you have a holiday on January 1st and New Year's Day, so the total number of working days this month is 22 days, and it is not counted as 23 days.

 

How to Get Your Question Answered Quickly 

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Power_It_Up
Helper I
Helper I

Syndicated - Outbound

@Idrissshatila @LeandroDeodato @v-yohua-msft 

Thank you all for your suggestions, which I applied but still couldn't quite get the calc to work.

I decided to dismantle the merge join and split them into separate tables and applying a relationship between them.  This fixed the issue.  Thanks again. 🙂

v-yohua-msft
Community Support
Community Support

Syndicated - Outbound

Hi, @Power_It_Up 

Based on your information, I create a sample table:

vyohuamsft_0-1722825136751.png

 

Then create a new measure and try the following dax:

TotalHours = 
CALCULATE(
    SUM('Table'[Hours]),
    FILTER(
        'Table',
        'Table'[Attend Date] >= DATE(2024, 1, 1) &&
        'Table'[Attend Date] <= DATE(2024, 1, 31) &&
        WEEKDAY('Table'[Attend Date], 2) <= 5
    )
)

Here is my preview:

vyohuamsft_1-1722825214327.png

 

The reason why the January data is different from your 146.74 is because I see that you have a holiday on January 1st and New Year's Day, so the total number of working days this month is 22 days, and it is not counted as 23 days.

 

How to Get Your Question Answered Quickly 

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

LeandroDeodato
Resolver II
Resolver II

Syndicated - Outbound

i think you need convert you hours column in seconds, than sum, and convert again in hours. 

Idrissshatila
Super User
Super User

Syndicated - Outbound

Hello @Power_It_Up ,

 

what if you extracted the month from the date and show the sum of hours by month, wouldn't this work ?

add a calculated column to get the month:

month name = format( datecolumn,"MMMM")



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




avatar user

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

Check out the March 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)