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
JoeKat07
Frequent Visitor

summing hours by project ID

I'm trying to create a new column that turns the first table into the second table. I'm trying to sum the hours that were done on each project.

 

Here is my code so far: NewColumn = sumx('Test Table', 'Test Table'[Hours])

 

 

image.pngimage.png

 

Thanks!!!!

6 REPLIES 6
v-jiascu-msft
Employee
Employee

Hi @JoeKat07,

 

Could you please mark the right post if it worked? More about this topic, please feel free to post here.

Best Regards!
Dale

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

@JoeKat07 You need to use a measure, not a calculated column. 

 

Measure = SUM('Test Table'[Hours])

Looking for more Power BI tips, tricks & tools? Check out PowerBI.tips the site I co-own with Mike Carlo. Also, if you are near SE WI? Join our PUG Milwaukee Brew City PUG

Great! that worked! now im trying to display the projects that have over 100 hours, between 100 and 95, between 95 and 90, and below 90. The first one works great! i've made a calculated column that is able to show that 5,6,8,9, and 10 all have over 100 hours. However when i try and make a new calculated column that shows the id's that are between 100 and 95 i get a circular reference error.

 

 image.png

 

i'm not sure where i have gone astray.

@JoeKat07 You can do the following static segmentation for this. (change to fit your needs)

 

First, create a seperate bucket table: (Buckets) - do not add a relationship to the other table, leave it disconnected.

Bucket	Min	Max
> 100	101	9999999999
100-95	96	100
95-90	91	95
< 90	0	90

then you can use the above table as a reference for the calculated column. Create the calculated column in your 'Test Table'

Group = CALCULATE (
    VALUES ( 'Buckets'[Bucket] ),
    FILTER (
        'Buckets',
        'Test Table'[Hours] >= 'Buckets'[Min] 
        && 'Test Table'[Hours] <= 'Buckets'[Max] 
    )
)

This gives you the bucket, and you can use the measure hours in your visual with the bucket and it works showing you something like this:

 

example.PNG

If you need to sort it, then add one more column to the bucket table to order them 1,2,3,4 and you can use the "Sort by Column" in the modeling header when you are in the data section.

 

 


Looking for more Power BI tips, tricks & tools? Check out PowerBI.tips the site I co-own with Mike Carlo. Also, if you are near SE WI? Join our PUG Milwaukee Brew City PUG

this works awesome if only row of data per grouping, but how do you get it to look at the total of all the rows with that same category (month, state, etc.), it said to do as measure instead of column, but that is not working using that measure in Calculated column and only works if hard code like "MI" for Michigan, but want a set of data to do for each State, how do you reference back to only give sum or whatever of all the rows that are the same month/state, etc. as that row?  have tried RELATED and VAR but nothing works

JoeKat07
Frequent Visitor

 

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.