Skip to main content
cancel
Showing results for 
Search instead 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.

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.

@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!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@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
Microsoft Fabric Learn Together

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

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors