cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ValeriaBreve
Helper IV
Helper IV

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-kalyj-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-kalyj-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
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

BizApps LATAM 2023

Business Application LATAM Summit 2023

Join the biggest FREE Business Applications Event in LATAM this February.

Power Platform Bootcamp

Global Power Platform Bootcamp

In this bootcamp we will deep-dive into Microsoft’s Power Platform stack with hands-on sessions and labs, delivered to you by experts and community leaders.

Top Solution Authors
Top Kudoed Authors