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
Deckard_X42
Frequent Visitor

SUM of Column if selected value is present in another column

Hello Everyone, 

 

I have been fiddeling with this issue for a long time without beeing able to find a solution, maybe you can help me. 

 

Here it is : 

 

I have a fact table with Client, Product and Amount : 

Deckard_X42_0-1634832868831.png

 

Also, I have dimension tables Client and Product that are related to the Fact table : 

Deckard_X42_1-1634833036621.png

 

I want to create a measure that give me the SUM of the "Amount" for every Client that have purchased specific Products. 

 

For instance, if I create a slicer and select the Product 3 : 

 

I want this measure to return the SUM of "Amount" filtered with only Client A and Client C but for all the products. 

 

In this case : Client A (92+3+79+47) + Client C (46+40+79+1). 

 

The issue is also that my Fact table is huge and I query it via DirectQuery and I cannot duplicate it with a SUMMARIZE or a GROUPBY. 

 

Is there a way to do it in the calculation directly? 

 

Idealy, I would like also to select multiple products and have the measure return the SUM for Client that have Product 6 AND/OR Product 3 for instance. 

 

Thank you in advance for your help, 

 

 

 

 

 

1 ACCEPTED SOLUTION

The issue is that the filters will filter the amount by product. 

 

The following measure will produce the desired output : 

 

Total Amount per Client if Product present =

VAR WithProduct =

VALUES( Client[Client] )

RETURN

CALCULATE(

[Total Amount],

REMOVEFILTERS( 'Product'[Product] ),

WithProduct
)

View solution in original post

2 REPLIES 2
lbendlin
Super User
Super User

Have you considered teaching your users how to use filters?

The issue is that the filters will filter the amount by product. 

 

The following measure will produce the desired output : 

 

Total Amount per Client if Product present =

VAR WithProduct =

VALUES( Client[Client] )

RETURN

CALCULATE(

[Total Amount],

REMOVEFILTERS( 'Product'[Product] ),

WithProduct
)

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