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
crisxp
New Member

Sum by Product with a filter

Hi All!

 

I am struggling to group by product with a filter on it.

 

I would like to create the column "Sum_Apple", having the sum of the Apple price for each customer.

 

CustomerProduct TypePriceSum_Apple
AApple100300
AApple200300
BApple200200
BBanana100200
CBanana2000
CBanana2000

 

 

I have been using CALCULATE(SUM(Table[Price],ALLEXCEPT(Table[Customer])), which calculates fine the total price for all products, but in the moment I add the filter (Product = "Apple"), then it only shows the price for each product, not at customer level.

 

Any suggestion?

Thank you in advance!

2 ACCEPTED SOLUTIONS
Samarth_18
Community Champion
Community Champion

Hi @crisxp ,

 

Please try this:-

Sum_Apple =
CALCULATE (
    SUM ( 'Table'[Price] ),
    FILTER (
        ALLEXCEPT ( 'Table', 'Table'[Customer] ),
        'Table'[Product Type] = "Apple"
    )
) + 0

 

Output:-

Samarth_18_0-1644844468764.png

 

Thanks,

Samarth

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

bcdobbs
Super User
Super User

Try the following it works for me with the data you sent:

Sum_Apple = 
    CALCULATE (
        SUM ( 'Table'[Price] ),
        ALLEXCEPT('Table', 'Table'[Customer] ),
        'Table'[Product Type] = "Apple"
    )

 

bcdobbs_0-1644845029672.png

 



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

View solution in original post

3 REPLIES 3
bcdobbs
Super User
Super User

Try the following it works for me with the data you sent:

Sum_Apple = 
    CALCULATE (
        SUM ( 'Table'[Price] ),
        ALLEXCEPT('Table', 'Table'[Customer] ),
        'Table'[Product Type] = "Apple"
    )

 

bcdobbs_0-1644845029672.png

 



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
crisxp
New Member

Thank you @Samarth_18 , I knew I was getting stucked in something that should be pretty easy. Thanks for your quick solution!!

Samarth_18
Community Champion
Community Champion

Hi @crisxp ,

 

Please try this:-

Sum_Apple =
CALCULATE (
    SUM ( 'Table'[Price] ),
    FILTER (
        ALLEXCEPT ( 'Table', 'Table'[Customer] ),
        'Table'[Product Type] = "Apple"
    )
) + 0

 

Output:-

Samarth_18_0-1644844468764.png

 

Thanks,

Samarth

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

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.