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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous_226
Frequent Visitor

Comparing mutliples tables and returing unique values

Hi,

 

I have a requirement for the following to be done in DAX. I cannot create and additonal columns as I am connected with direct query to a dataset.

 

I have a scenario with 2 seperate tables that are related by a number column.

Table A
Number | Fruit
1            | Apple

2            | Orange

3            | Strawberry

4            | Grape

5            | Plum

1            | Kiwi

2            | Kiwi

Table B

Order     | Number
               | 1

               | 2

00367     | 3

00485     | 4

00059     | 5

00689     | 6

00745     | 8

 

Here is what I am looking to accomplish:
1. The first thing I need to do is take Table A and remove any row that has the Kiwi in the fruit column.

2. I need to take the values in the number column of Table A and find wich of those are not present in the number column in Table B

Thanks,

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Anonymous_226 

 

You can try the following methods.
New Table:

Table = FILTER('Table A',[Fruit]<>"Kiwi")

vzhangti_0-1678348513587.png

Table B:

vzhangti_1-1678348545242.png

Measure = 
Var _table=EXCEPT(VALUES('Table'[Number]),VALUES('Table B'[Number]))
Return
IF(SELECTEDVALUE('Table'[Number]) in _table,1,0)

vzhangti_2-1678349092408.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

10 REPLIES 10
v-zhangti
Community Support
Community Support

Hi, @Anonymous_226 

 

You can try the following methods.
New Table:

Table = FILTER('Table A',[Fruit]<>"Kiwi")

vzhangti_0-1678348513587.png

Table B:

vzhangti_1-1678348545242.png

Measure = 
Var _table=EXCEPT(VALUES('Table'[Number]),VALUES('Table B'[Number]))
Return
IF(SELECTEDVALUE('Table'[Number]) in _table,1,0)

vzhangti_2-1678349092408.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous_226
Frequent Visitor

@andhiii079845that makes a bit more sense then. TableA has a 1:n relationship to TableB so i would be looking from the "1" to the "n"

tamerj1
Super User
Super User

Hi @Anonymous_226 

please place the following filter measure in the filter pane of the table visual, select "is not blank" and apply the filter 

FilterMeasure =
COUNTROWS (
FILTER (
TableA,
TableA[Fruit] <> "Kiwi"
&& TableA[Number]
IN CALCULATETABLE ( VALUES ( TableB[Number] ), TableB[Order] = BLANK () )
)
)

@tamerj1Thank you for that. What I am seeing is that gives me all of the numbers from TableA that are present in TableB. However in the comments below I am needing to get all the numbers in TableA that are not in TableB. I cant see to correct the measure properly to achieve that. Do you have any suggestions?

@Anonymous_226 

Seems to working. I even tried a 2nd option. See below and refer to attached sample file. Please provide sample data that accurately simulates you real one.

1.png2.png3.png

@tamerj1in my relationship TableA a 1:* with TableB. Would that make a difference? When I try your "FilterMeasure 2" i get an error saying there is no relationship available from TableB[order]

@Anonymous_226 

As per the sample data, TableA is the many and TableB is the one not the opposite. Again please double check and provide correct sample data. 

andhiii079845
Solution Sage
Solution Sage

Try this:

Measure = 
VAR __table1 = CALCULATE(countrows(TableA),RELATEDTABLE(TableB),Filter(TableA,TableA[Fruit]<>"Kiwi"),Filter(TableB,TableB[Order]=BLANK()))
Return __table1


The result:

andhiii079845_0-1677653621575.png

 





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

Proud to be a Super User!




@andhiii079845Thank you for that. That helped get me in the right direction. The one thing I am noticing now that I am taking another look at it is that I actually need to return the numbers that are not in Table B.

I have part of the measure you provided me:

Measure = 
VAR __table1 = CALCULATE(countrows(TableA),RELATEDTABLE(TableB),Filter(TableA,TableA[Fruit]<>"Kiwi")))
Return __table1

This gives me the numbers from TableA that are also in TableB which is what I had orginally thought I needed but now I am looking at the data and I need the numbers from TableA that are not in TableB. I seem to be having trouble modifying that measure properly. Any suggestions?

 

Thank you for the help.

If you change the "direction" of the search / look up, you need to change relatedtable to related. Both depands of the relationship: 1:n. Do you look from "1" to the "n" table or do you look from "n" to the "1" table. 





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.