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
ImreP
Helper I
Helper I

Values of all related clients based on product filter

Hi,

 

I have a requirement where I need to get the values of all products of all clients that has a product a user filters.

 

Here is the example:

 

ProductClientVolumeExpected volume
C1121x
M11000x
D1200x
C2112x
D2300x
M32000 
D4400x
C4154x
  42872287

 

Let's say the user slices by Product 'C'. In this case the required Measure result is the sum of all products where any clients has product 'C'. Then 'Expected volume' marks which volumes should be included in the result in case of product 'C' filter.

 

In SQL I'd do the following:

 

select
sum(Volume)
from table

where client in

(select
client
from table
where product='C')

 

But I need this to be dynamic therefore I think it should be written in a measure. 

 

Could you please help me with this?

 

Thanks.

6 REPLIES 6
Greg_Deckler
Community Champion
Community Champion

@ImreP Try:

Measure =
  VAR __Clients = DISTINCT('Table'[Client])
  VAR __Table = FILTER(ALL('Table'),[Client] IN __Clients)
RETURN
  SUMX(__Table,[Volume])


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

It's not fast. Actually it does not give a result after minutes. I was out of memory after about 7 minutes. 

 

I guess it is expected to be slow. 

 

Are there any options that are less resource intensive? It could be tables, measures. The data model is much more complex than my example and there are multiple filters in the user's hand. All other filters should work as "normal". But testing on my sample table, your formula does just that, so I would think your formula would result in the desired output. 

 

@Greg_Deckler 

@ImreP You can try something like this:

Measure =
SUMX(
	KEEPFILTERS(DISTINCT('Table'[Client])),
	CALCULATE(SUM('Table'[Volume]))
)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler The performance is okay but the result is wrong. Only the chosen product is taken into account on client level. 

@ImreP Yeah, the joys of CALCULATE, maybe this:

Measure =
SUMX(
	KEEPFILTERS(DISTINCT('Table'[Client])),
	CALCULATE(SUM('Table'[Volume]),ALL('Table'))
)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thanks! Looks good on the example. I'm going to try it on the actual data model. 

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
Top Kudoed Authors