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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

How to check if value is in another table with additional condition and print 0 or 1

Hi,

 

I'm trying to build a command to first check if a value is in one of two tables while fulfilling a condition, and then print either 0 or 1 to a column. I'm having trouble combining these all to one command.

 

So, first I want to check if a value on table1 is on table2 or table3 AND marked on the same row as type a. If the value is found on either of the tables as type a, then command should return 1 to the column on table 1. Otherwise, if the value is not found or is not marked type a, it should return 0 to the column.

 

I'm basically wanting to combine an IF ELSE structure with an additional condition. How could this be done efficiently?

 

1 REPLY 1
ValtteriN
Super User
Super User

Hi,

I am not sure if I understood, but here is an attempt:

Table1:

ValtteriN_0-1699795796047.png

Table2

ValtteriN_1-1699795865677.png

Table3:

ValtteriN_2-1699795922543.png

Here in table1 we have Type A Dimension AA and Type B dimension AA which are found in table 2 or 3 with matching values. These rows should get a value 1 in our dax.

Dax:

Test for match in tables with matching values in filter context =
var _type = MAX('Table (16)'[Type])
var _dimension = MAX('Table (16)'[Dimension])
var _testTable2 = COUNTROWS(FILTER('Table (17)','Table (17)'[Type]=_type && 'Table (17)'[Dimension] = _dimension))
var _testTable3 =  COUNTROWS(FILTER('Table (18)','Table (18)'[Type]=_type && 'Table (18)'[Column1] = _dimension)) //filter the test tables with the current context values
return
IF(OR(_testTable2>0,_testTable3>0),1,0)


End Result:

ValtteriN_3-1699796422889.png

 

The result seems to match the expectation.

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/





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

Proud to be a Super User!




Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.