Reply
Elichka
Resolver I
Resolver I
Partially syndicated - Outbound

Query with Not In (select * from table)

Hello, I need to create report using query with multiple not in statements.

select email
from table1 a
where a.email not in ( select email from table2 )
and a.email not in ( select email from table3 )

and a.email not in ( select email from table4 )

 

Where table1, table2,  table3 and table4 are not related

Im using power bi with Direct Query mode.

 

Any ideas/help is greatly appreciated!

1 ACCEPTED SOLUTION
v-jiewu-msft
Community Support
Community Support

Syndicated - Outbound

Hi @Elichka ,

Based on my testing, please try the following methods again:

1.Create the simple tables.

vjiewumsft_0-1717723216711.png

vjiewumsft_1-1717723238367.png

vjiewumsft_2-1717723247718.png

vjiewumsft_3-1717723255853.png

2.Create the new table to filter the email.

filtered_data = 
var tab2 = SELECTEDVALUE(Table2[Email])
var tab3 = SELECTEDVALUE(Table3[Email])
var tab4 = SELECTEDVALUE(Table4[Email])
RETURN
CALCULATETABLE('Table1', NOT('Table1'[Email] IN {tab2, tab3, tab4}))

3.Drag the new table into the table visual. The result is shown below.

vjiewumsft_4-1717723263174.png

Best Regards,

Wisdom Wu

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

2 REPLIES 2
v-jiewu-msft
Community Support
Community Support

Syndicated - Outbound

Hi @Elichka ,

Based on my testing, please try the following methods again:

1.Create the simple tables.

vjiewumsft_0-1717723216711.png

vjiewumsft_1-1717723238367.png

vjiewumsft_2-1717723247718.png

vjiewumsft_3-1717723255853.png

2.Create the new table to filter the email.

filtered_data = 
var tab2 = SELECTEDVALUE(Table2[Email])
var tab3 = SELECTEDVALUE(Table3[Email])
var tab4 = SELECTEDVALUE(Table4[Email])
RETURN
CALCULATETABLE('Table1', NOT('Table1'[Email] IN {tab2, tab3, tab4}))

3.Drag the new table into the table visual. The result is shown below.

vjiewumsft_4-1717723263174.png

Best Regards,

Wisdom Wu

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

Syndicated - Outbound

Hello, sorry to take me so long to test your solution...

Unfortunately when i tried got this error - 

The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.
Also, I can't open your pbix as we use older version...
Thank you any way, may be you know another way of doing that? Appreciate your help!!!
avatar user

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

Check out the March 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)