PowerQuery Lookup Key(s)

cmcreynolds

Active Member
Joined
May 21, 2015
Messages
295
It's 2016 and I want to improve my existing reports. This basically boils down to using text as keys to match up two datasets.

(BTW, I'm running Office 2016 w/PowerQuery built in - so far so good!)

What I did in the past was built a relationship based on these two key fields, then added a dummy variable so I can sort on ONLY those records with connections:

=IF(Table1[Key1]=RELATED(Table2[Key2]),1,0)

Works just fine - unless there's a duplicate in Key2 (which the people entering data don't realize they do, but it's quite often).

So, I was wondering if there's a workaround using LOOKUPVALUE...but if I'm not mistaken, it needs a "result" argument in order to execute, instead of just a "yep, there is a match!" Also, I think if there's a duplicate in my Table2, it'll error out.

Oh - and does the key have to be sorted in order for LOOKUPVALUE to work?

I just want it dummy coded again so I can filter, I don't need to return any values.

Thank you.
 
Last edited:

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Since there may be duplicates, i suggest you not have a defined relationship between the tables. Then this should work as calculated column:
=if(calculate(countrows(Table2),filter(Table2,Table2[key2]=Table1[Key1]))>1,1,0)
 
Upvote 0

Forum statistics

Threads
1,224,146
Messages
6,176,666
Members
452,739
Latest member
SCEducator

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top