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

CALCULATE with an OR condition for multiple FILTER conditions across multiple tables

I have a list of computer names joined to two tables. I want to write a calculate statement that tests if the computer name in the primary list matches to either of the joined tables and only count it once.

 

Something to the effect of =CALCULATE(DISTINCTCOUNT(Table1[Computer Name]), FILTER(Table2, Table2[Computer Name] <> BLANK()) OR FILTER(Table3, Table3[Computer Name] <> BLANK()))

 

That is a simplified example. For complexity reasons I cannot combine the two tables so that I have a single join. 

1 ACCEPTED SOLUTION
AM_XRX
Frequent Visitor

I ended up using an anti-join in Power Query so that Table3 did not contain any Computer Name values present in Table2, that way my measure could be =CALCULATE(DISTINCTCOUNT(Table1[Computer Name]), FILTER(Table2, Table2[Computer Name] <> BLANK()) + CALCULATE(DISTINCTCOUNT(Table1[Computer Name]), FILTER(Table3, Table3[Computer Name] <> BLANK())).

 

This workaround yeilded the correct answer but I am still curious if there is a way count unique matches across multiple table joins each with their own filter criteria.

View solution in original post

3 REPLIES 3
AM_XRX
Frequent Visitor

I ended up using an anti-join in Power Query so that Table3 did not contain any Computer Name values present in Table2, that way my measure could be =CALCULATE(DISTINCTCOUNT(Table1[Computer Name]), FILTER(Table2, Table2[Computer Name] <> BLANK()) + CALCULATE(DISTINCTCOUNT(Table1[Computer Name]), FILTER(Table3, Table3[Computer Name] <> BLANK())).

 

This workaround yeilded the correct answer but I am still curious if there is a way count unique matches across multiple table joins each with their own filter criteria.

v-jiascu-msft
Employee
Employee

Hi @AM_XRX,

 

If you want to count the computers, you could try to bring all the columns of "computer" together with this formula. Then it's easy to count the items.

 

Table =
DISTINCT ( UNION ( VALUES ( Table1[Computer] ), VALUES ( Table2[Computer] ) ) )

Or we could find out if one item exist in another table with this formula.

existinanother =
LOOKUPVALUE ( Table2[Computer], Table2[Computer], Table1[Computer] )

CALCULATE with an OR condition for multiple FILTER conditions across multiple tables.jpg

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Best Regards!

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
GilbertQ
Super User
Super User

You could use the "||" instead of the OR and see if that works.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

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