Forum Discussion

Scaffnull's avatar
Scaffnull
Icon for Helper I rankHelper I
4 years ago
Solved

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:

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

 

4 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    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.

    • Scaffnull's avatar
      Scaffnull
      Icon for Helper I rankHelper I

      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.

       

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

  • v-jingzhang's avatar
    v-jingzhang
    Icon for Community Support rankCommunity 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]))

     

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

    • Scaffnull's avatar
      Scaffnull
      Icon for Helper I rankHelper I

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