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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
ValeriaBreve
Post Patron
Post Patron

lookup table values using a filter

Hello,

I have 2 tables, A and B.

I need to lookup column "ID" from table A, but only for the values of table B related column "ID2" are not null.

 

I would normally do a merge, only how do I handle the condition?

 

Thanks!

Kind regards

Valeria

 

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

Hi @ValeriaBreve ,

According to your description, you want to do a conditional merge queries. Here's my solution.

Sample data:

TableA:

vkalyjmsft_0-1669950084396.png

TableB:

vkalyjmsft_1-1669950129825.png

In my understanding, for null value in TableB, after merge queries with TableA, you want to return blank instead of 40(Sales for null in TableA).

Here's the original code when doing the general merge. Simply replace the three parameter in the Table.NestedJoin-"TableA" to "Table.SelectRows(#"TableA",each [ID]<>null)".

vkalyjmsft_3-1669950510941.png

                                         vkalyjmsft_6-1669950694948.png

 

vkalyjmsft_5-1669950634186.png

Get the correct result:

vkalyjmsft_7-1669950820511.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

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-yanjiang-msft
Community Support
Community Support

Hi @ValeriaBreve ,

According to your description, you want to do a conditional merge queries. Here's my solution.

Sample data:

TableA:

vkalyjmsft_0-1669950084396.png

TableB:

vkalyjmsft_1-1669950129825.png

In my understanding, for null value in TableB, after merge queries with TableA, you want to return blank instead of 40(Sales for null in TableA).

Here's the original code when doing the general merge. Simply replace the three parameter in the Table.NestedJoin-"TableA" to "Table.SelectRows(#"TableA",each [ID]<>null)".

vkalyjmsft_3-1669950510941.png

                                         vkalyjmsft_6-1669950694948.png

 

vkalyjmsft_5-1669950634186.png

Get the correct result:

vkalyjmsft_7-1669950820511.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

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

Thanks! This looks so easy... I was trying solutions that were more complicated, I did not know you could declare a subset of the table in the merge function ! So thank you so much for showing me 🙂

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors
Top Kudoed Authors