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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Sum with grouping step

Hi everyone !

 

I have a simple table, like this one : 
Capture1.PNG

I want to create a measure with different steps : 
1 - Sum "Qty" column grouping on "Product" column
2 - Evaluate if the result of "Step 1" is negative. If it's true, return 0 else return "Step 1"
3 - Sum "Step 2" 

The result i'm expecting for this dataset is : 27
I can't specify in my measure every products with a switch formula because in my original dataset there is between 700 and 3500 different cases.
An important information is that, in the bar chart which will show the measure evolution through time, there is no "Product" filter context. 

Any idea ? 🙂

 

1 ACCEPTED SOLUTION
M_L
Frequent Visitor

Hi @Anonymous 

This measure may help

M_Product = 
VAR __Step1 = SUMMARIZE(TableProduct;TableProduct[Product];"TotalProduct";sum(TableProduct[Qty]))
VAR __Step2and3 = CALCULATE(SUM([Qty]);FILTER(__Step1;[TotalProduct]>0))
RETURN __Step2and3

Let me know if that is fine. 

View solution in original post

2 REPLIES 2
M_L
Frequent Visitor

Hi @Anonymous 

This measure may help

M_Product = 
VAR __Step1 = SUMMARIZE(TableProduct;TableProduct[Product];"TotalProduct";sum(TableProduct[Qty]))
VAR __Step2and3 = CALCULATE(SUM([Qty]);FILTER(__Step1;[TotalProduct]>0))
RETURN __Step2and3

Let me know if that is fine. 

Anonymous
Not applicable

Hi @M_L,

This is perferct thanks for your time !

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.