cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Scaffnull
Helper I
Helper I

Gather a sum function and place the value in another row in a table

Hi everyone, 

 

Have a issue I try to solve. Right now in the data I collect there's a column for Scope with 4 different options, and only one of those options "Work" there is a value (hours). That scope is tied to a unique ID, and there can be lots of hours submitted on different dates on to one unique ID. Another Scope value is "Finished Work" which always has 0 hours.  I would like to create a formula so it gathers the sum of hours and place it in "Finished Work" row just for that unique ID. ("Finished work" is tied to "Work", so it has the same ID).

Example on the picture below:

Skärmavbild 2021-11-23 kl. 14.22.28.png

Here I want to have the total hours next to "Finished Work"

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @Scaffnull 

 

You can create below measure and put it in the matrix as Values field.

Total Hours = IF(SELECTEDVALUE('Table'[Scope])="Finished work", CALCULATE(SUM('Table'[Hours]),ALL('Table'[Date])), SUM('Table'[Hours]))

21112605.jpg

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

4 REPLIES 4
v-jingzhang
Community Support
Community Support

Hi @Scaffnull 

 

You can create below measure and put it in the matrix as Values field.

Total Hours = IF(SELECTEDVALUE('Table'[Scope])="Finished work", CALCULATE(SUM('Table'[Hours]),ALL('Table'[Date])), SUM('Table'[Hours]))

21112605.jpg

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

@v-jingzhang Perfect! This worked just like I wanted to, just had to rename to the correct tables 🙂 thank you very much!

Greg_Deckler
Super User
Super User

@Scaffnull Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


@ me in replies or I'll lose your thread!!!
Check out my External Tool for Power BI Desktop! Microsoft Hates Greg's Quick Measures
YouTube Channel! Microsoft Hates Greg
Check out my latest book!

@Greg_Deckler Thank you for your reply! So the source of the data comes from a report system. Where the workers does a job and can choose different types of work, depending on the type of work it records in the column from the excel sheet. So example, ID 100 they did "Hours" (records in the scope column) and value is 25 hours. This can be repeated so the next day they did another job under ID 100 with "Hours" 55. So now on two different rows it has 25 and 55 hours. On day 3 they "Finished Work" and no hours is put in. I would like to have the 80 hours worked placed on "Finished Work". And this repeated for example ID 240 that has 120 value based on the hours worked.

 

Skärmavbild 2021-11-23 kl. 17.19.49.png

 So based on this picture have 40 + 220 stand as 260 on the last line. Hope that makes better sense 🙂 

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors