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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Calculate SUM of Hours in week

Hello All,

 

I have got a table which has Employee Name, Date and Hours Worked. See data below - 

 

 

DateEmployee NameWeek NumberHours WorkedExpected Result
02/11/2020ABC7234
02/12/2020ABC7234
02/11/2020ABC7334
02/12/2020ABC7334
02/13/2020ABC7834
02/14/2020ABC7834
02/15/2020ABC7834
02/11/2020XYZ7842
02/12/2020XYZ7842
02/13/2020XYZ7842
02/14/2020XYZ7842
02/15/2020XYZ71042

 

So what I would like to do is calculate the hours by ABC in week 7. The week starts on Thursday. So on and so forth.

 

Thanks in Advance.

 

1 ACCEPTED SOLUTION
v-jayw-msft
Community Support
Community Support

Hi @Anonymous ,

 

Try this formula please.

Column = CALCULATE(SUM('Table'[Hours Worked]),FILTER('Table','Table'[Employee Name]=EARLIER('Table'[Employee Name])&&'Table'[Week Number]=EARLIER('Table'[Week Number])))

2.PNG 

 

Best Regards,

Jay

 

Community Support Team _ Jay Wang

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

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

View solution in original post

8 REPLIES 8
v-jayw-msft
Community Support
Community Support

Hi @Anonymous ,

 

Try this formula please.

Column = CALCULATE(SUM('Table'[Hours Worked]),FILTER('Table','Table'[Employee Name]=EARLIER('Table'[Employee Name])&&'Table'[Week Number]=EARLIER('Table'[Week Number])))

2.PNG 

 

Best Regards,

Jay

 

Community Support Team _ Jay Wang

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

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
az38
Community Champion
Community Champion

Hi @Anonymous 

if I understand you correct you need a measure like

CALCULATE(SUM(Table[Hours Worked]), ALLEXCEPT(Table, Table[Employee Name], Table[Week Number]) )

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

@az38 I am not looking to add a measure. I need a calculated column.

az38
Community Champion
Community Champion

@Anonymous 

it will have completely the same formula


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

@az38 I had already tried this solution. It gives incorrect solution.

 

For example, for employee ABC the total hours come out as 40. The answer is same for Column and measure.

Hi @Anonymous,

the measure or formula for the calculated column of @az38 with your sample data is correct:

 

25-06-_2020_00-47-10.jpg

 

Regards FrankAT

 

Anonymous
Not applicable

@FrankAT & @az38  what could affect a different result. 

Let's suppose I have more columns than this and multiple rows are not the same but Employee Name, Week Number is the same. Is that the reason I am not getting the correct result.

az38
Community Champion
Community Champion

@Anonymous 

it shouldn't be as ALLEXCEPT() remove all filters except Employee Name and Week Number

Check your data first.


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.