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
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
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.

Top Solution Authors