Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
tonyclifton
Helper III
Helper III

Aggregate Sum based on Column

Hello community,

 

I am doing my first steps with Power BI and now I've gotten to a point where I require some help.

In below example I have row values that need to be aggregated based on the ParentID

 

If the sum of Current for all rows of that ParentID is greater than ZERO, then put this value in another measure/column which can be used in other calcuations.

At the moment I use a "Combined" column which gives wrong sums because I can only check each row if a Current value exists.

The correct sum for those two examples is 3350 and 10.

 

 

x.PNG

 

Let me know if you need more details.

 

Hope you can help me.

 

Best regards,

Thorsten

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @tonyclifton

measure below

Combined = IF(SUM(Sheet5[Current])>0,SUM([Current]),0)

17.png

Best Regards

Maggie

View solution in original post

3 REPLIES 3
v-juanli-msft
Community Support
Community Support

Hi @tonyclifton

measure below

Combined = IF(SUM(Sheet5[Current])>0,SUM([Current]),0)

17.png

Best Regards

Maggie

vanessafvg
Super User
Super User

@tonyclifton

 

might be an easier way but what i would first do is summarize the table

 

ie. summary = SUMMARIZE(Table2, Table2[ParentID], "TotalCurrent", sum(Table2[Current]))

 

then i would create a relationship between the 2 tables on parentid

 

then i would create a measure in the first table

test = if(sum(summary[TotalCurrent]) > 0, sum(summary[TotalCurrent]), 0)





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




@vanessafvgthank you. This seems to do the trick to get the correct sums. However I missed to add one important column to the example which is needed to present the values by a status.

Each ChildID can have a different Status

 

If the sum of Current for a ParentID is greater than zero, set the value of the "Combined" column to zero where a Budget value exists in order to also get the correct values for each row.


Example:

y.PNG

 

Is that possible?


Thanks.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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