Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric certified for FREE! Don't miss your chance! Learn more

Reply
webportal
Impactful Individual
Impactful Individual

CALCULATE with OR condition in two tables

Hello,

 

In order to Sum the sales amount of blue products OR products that belong to category shoes, I'm using the following DAX expression:

 

CALCULATE(

SUM(Table[SalesAmount]),

FILTER(

Table,

Table[Color] = "Blue" ||

Table[Category] = "Shoes")

)

However, this doesn't work with two different tables (Colors and Categories), like:

 

CALCULATE(

SUM(Table[SalesAmount]),

FILTER(

Table,

Colors[Color] = "Blue" ||

Categories[Category] = "Shoes")

)

Can anyone help?

 

Thanks!

1 ACCEPTED SOLUTION
Phil_Seamark
Microsoft Employee
Microsoft Employee

Hi @webportal

 

I got this working in a calculated measure.  You may just need to add the RELATED function to the OR condition

 

CALCULATE(
	SUM('Table'[SalesAmount]),
	FILTER(
		'Table',
		RELATED(Colors[Color]) = "Blue" || 
		RELATED(Categories[Category]) = "Shoes")
	)

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

3 REPLIES 3
Phil_Seamark
Microsoft Employee
Microsoft Employee

Hi @webportal

 

I got this working in a calculated measure.  You may just need to add the RELATED function to the OR condition

 

CALCULATE(
	SUM('Table'[SalesAmount]),
	FILTER(
		'Table',
		RELATED(Colors[Color]) = "Blue" || 
		RELATED(Categories[Category]) = "Shoes")
	)

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Sure, it works pretty well, thank you!
I suppose the "theory" behind this solution is to "bring" the Colors and Categories tables to the Table, treating them as one.
Really cool!

Yeah, having relationships is effectly giving you a logical table that includes all the columns from the table on the 1 side of the relationship on the table from the many side.

 

Good to hear it works!


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.