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
Anonymous
Not applicable

Desperate in setting the right filter!

Hi Community,

 

I'm desperately looking into a way of having appropriate filters in a matrix table set. This is my problem:

 

I have a matrix table that contains customer's names (row) and 2 columns representing the revenues of a new and old product. Customers not necessarily buy one product exclusively; once filtered on e.g. the new product it should show also the revuene of the old product (if available). In my ideal world I have the ability to choose the following 3 conditions: 1) Show customers only buying new product, 2) show customers currently buying both products and 3) show customers only buying old products.

 

Any suggestions? 

 

Many thanks in advance!

 

BTW: I'm a noobie in PBI and pls forgive me in asking this basic question.

 

 

 

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Anonymous , Create measures like these. Assumes new and old are product type

 

count of customer buying only new product = countx(filter(summarize(Table, table[customer], "_1", distinctCOUNT(Table[Product Type]), "_2", calculate(distinctCOUNT(Table[Product Type]), filter(Table, Table[Product Type]="New"))+0), [_2]>0 && [_1] =[_2]),[customer])

 

count of customer buying only old product = countx(filter(summarize(Table, table[customer], "_1", distinctCOUNT(Table[Product Type]), "_2", calculate(distinctCOUNT(Table[Product Type]), filter(Table, Table[Product Type]="Old"))+0), [_2]>0 && [_1] =[_2]),[customer])

 

count of customer buying both products = countx(filter(summarize(Table, table[customer], "_1", distinctCOUNT(Table[Product Type])), [_1] =2),[customer])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

littlemojopuppy
Community Champion
Community Champion

Hi!  You can easily determine customers buying old only, new only or both with table manipulation functions.  You can create three measures...each will have identical variables and the only difference will be which of the three statements you use after the RETURN statement.

VAR	CustomersBuyingOld =
	CALCULATETABLE(
		VALUES(Table[CustomerID]),
		FILTER(
			Table,
			Table[Product[ID] = [OldProductID]
		)
	)
VAR	CustomersBuyingNew =
	CALCULATETABLE(
		VALUES(Table[CustomerID]),
		FILTER(
			Table,
			Table[Product[ID] = [NewProductID]
		)
	)
RETURN

-- For Customers Buying Old Only
EXCEPT(
	CustomersBuyingOld,
	CustomersBuyingNew
)

-- For Customers Buying New Only
EXCEPT(
	CustomersBuyingNew,
	CustomersBuyingOld
)

-- For Customers Buying Both Old & New
INTERSECT(
	CustomersBuyingOld,
	CustomersBuyingNew
)

 Note that the DAX above will return tables.  If you need customer counts, place the EXCEPT() or INTERSECT() inside COUNTROWS().  If you need sales for each group of customers you can do something like this for which group of customers you need.

CALCULATE(
	SUM([Sales]),
	INTERSECT(
		CustomersBuyingOld,
		CustomersBuyingNew
	)
)

Hope this helps!

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Thx guys; you really helped me out!

littlemojopuppy
Community Champion
Community Champion

Hi!  You can easily determine customers buying old only, new only or both with table manipulation functions.  You can create three measures...each will have identical variables and the only difference will be which of the three statements you use after the RETURN statement.

VAR	CustomersBuyingOld =
	CALCULATETABLE(
		VALUES(Table[CustomerID]),
		FILTER(
			Table,
			Table[Product[ID] = [OldProductID]
		)
	)
VAR	CustomersBuyingNew =
	CALCULATETABLE(
		VALUES(Table[CustomerID]),
		FILTER(
			Table,
			Table[Product[ID] = [NewProductID]
		)
	)
RETURN

-- For Customers Buying Old Only
EXCEPT(
	CustomersBuyingOld,
	CustomersBuyingNew
)

-- For Customers Buying New Only
EXCEPT(
	CustomersBuyingNew,
	CustomersBuyingOld
)

-- For Customers Buying Both Old & New
INTERSECT(
	CustomersBuyingOld,
	CustomersBuyingNew
)

 Note that the DAX above will return tables.  If you need customer counts, place the EXCEPT() or INTERSECT() inside COUNTROWS().  If you need sales for each group of customers you can do something like this for which group of customers you need.

CALCULATE(
	SUM([Sales]),
	INTERSECT(
		CustomersBuyingOld,
		CustomersBuyingNew
	)
)

Hope this helps!

 

amitchandak
Super User
Super User

@Anonymous , Create measures like these. Assumes new and old are product type

 

count of customer buying only new product = countx(filter(summarize(Table, table[customer], "_1", distinctCOUNT(Table[Product Type]), "_2", calculate(distinctCOUNT(Table[Product Type]), filter(Table, Table[Product Type]="New"))+0), [_2]>0 && [_1] =[_2]),[customer])

 

count of customer buying only old product = countx(filter(summarize(Table, table[customer], "_1", distinctCOUNT(Table[Product Type]), "_2", calculate(distinctCOUNT(Table[Product Type]), filter(Table, Table[Product Type]="Old"))+0), [_2]>0 && [_1] =[_2]),[customer])

 

count of customer buying both products = countx(filter(summarize(Table, table[customer], "_1", distinctCOUNT(Table[Product Type])), [_1] =2),[customer])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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