cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Dorinda
Super User
Super User

Split hours worked into weeks of the month

I have an app that I have a column called Work Hours this is a rollup of all of the hours entered by the user.  I need to split the hours into each respective week of the month to show how many hours are being worked in each week.

Dorinda_0-1658414422362.png

This is all in a SharePoint list so the data has the actual date it was entered in the app captured in SharePoint.

Dorinda_1-1658414508419.png

How can I do this?

5 REPLIES 5
WiZey
Super User
Super User

Hello @Dorinda ,

 

With "WeekNum()" you can check if the week number the employee entered his work hours is the same as the week number you're displaying in your table.

@WiZey 

 

I made some progress in my gallery getting the week number 

Dorinda_0-1658419797591.png

 

 

Now I need to sum up each of those weeks to get total for each week.  That is where I am stuck now.

WiZey
Super User
Super User

If I understood you well, using your picture as example, you want the sum of the "Total Hours" of each day for a specific "Week Number"?

 

I don't know how your app was built, so the best solution I can give you is this formulae:

 

 

Sum(Filter(cltYourCollection;WeekNum(yourDate) = WeekNum(currentDate));'Total Hours')

 

 

Basically, you're giving the "Sum()" function a table of all records whose week number is equal to the week number you're looking for. The second parameter should be the column corresponding to the "Total Hours" (it's also an expression, so you can put in an arithmetic operation such as an addition of multiple columns if you need).

This is giving me all kinds of errors,  I have the collection called colpwrsysele, this has all of the information from the SharePoint list.  My Date field in SharePoint is Called Date (yes I know i blew that one), but I am not sure if that is correct

Sum(Filter(colpwrsysele;WeekNum(DatePicker1_2.SelectedDate) = WeekNum(DatePicker1_2.SelectedDate));'Total Hours')

 because I am getting all kinds of errors 

WiZey
Super User
Super User

Could you give the list of the errors you're encountering please?

 

Is "Total Hours" part of your SharePoint list, or is it calculated inside your app?

 

By the way, you're comparing "WeekNum(DatePcker1_2.SelectedDate)" with itself, which will always return "true". In my exemple, I was suggesting comparing "WeekNum(collection.Date)" with "WeekNum(DatePicker.SelectedDate)", which should return "true" only if the date of the record has the same week number as the date selected in the datepicker.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,253)