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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Shimpei
Regular Visitor

How to sum by groups and add a filter

How can I create a measure?
I would like to sum "Revenue" and "Margin" by "Customer" and add a filter by sum results for "Margin" (i.e. Margin > 0, Margin <=0)
This is the raw table

Shimpei_1-1677540317945.png

 

My goal is to make the table like this out of above data.

 

Shimpei_2-1677540349762.png

 

 

2 REPLIES 2
amitchandak
Super User
Super User

@Shimpei , Create a measure like

 

BU Customer = calculate(Sum(Table[Margin]), filter(allselected(Table), Table[Customer] = max(Table[Customer])  && Table[business Unit] = max(Table[business Unit])  ))

 

Postitive = calculate(Sum(Table[Margin]), filter( Table, [BU Csutomer]>0 ) )

 

Negative= calculate(Sum(Table[Margin]), filter( Table, [BU Csutomer]<0 ) )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you. 
One thing that I would like to achive is that I want to filter based on whether the margin is posive for "Business Unit 1" or not. Right now it is filtering the positive and negative for each business unit, but is there anyway that I can filter based on Business Unit 1 results?

Shimpei_0-1677598578224.png

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors