Vlookup help and alternative

reporting_95

New Member
Joined
May 7, 2019
Messages
30
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hello,
In my reports, I am using vlookup to fill blank rows and columns with data that comes from a different workbook. This works but its tidious to have to either type in the formula in each cell or use the Lookup & Reference option in each column. Please see the example below:
This the full data workbook:
Client IDLast NameFirst NameItemCost
515155SmithJohnBook$1.50
515156DoeJaneBox$10.50
515158HayesCharlesChair$11.50
515158RodriguezAlexBaseball$5.00
515159JeterDerekGlove$30.00
515160JordanMichaelSneakers$150.00
515161MertzEthelDress$100.00
515162DraperDonSuit$1,000.00
515163WalkerKarenPurse$500.00
And this is my report:

Client IDYear of PurchaseSale TypeLast NameFirst NameItemCost
5151582020FinalHayesCharlesChair$11.50
5151622020FinalDraperDonSuit$1,000.00
5151592020FinalJeterDerekGlove$30.00
5151632020FinalWalkerKarenPurse$500.00
5151562020FinalDoeJaneBox$10.50
5151612020FinalMertzEthelDress$100.00
5151602020FinalJordanMichaelSneakers$150.00
5151602020FinalJordanMichaelSneakers$150.00

I use the client ID in vlookup to fill the columns in my report. The formula I use is =VLOOKUP(A2,[Book1]Sheet1!$A$2:$B$10,2,FALSE). Is there an easier, more efficient way to get the data in my report without having to use vlookup all the time?

Thanks!
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
If you post your second table, I can probably show you how to do this in Power Query by joining the two tables. Fairly quick and simple to do.
 
Upvote 0
If you post your second table, I can probably show you how to do this in Power Query by joining the two tables. Fairly quick and simple to do.


Hi alansidman,

Below is the second table, or better yet what my report would look like. I purposely added 2 additional columns that are not in the first table because there are times I have to manually insert columns with fill data. Also, you'll see there are some names that appear twice. That's also done by design, because there are also times my report must show the duplicates.

Client IDYear of PurchaseSale TypeLast NameFirst NameItemCost
5151582020FinalHayesCharlesChair$11.50
5151622020FinalDraperDonSuit$1,000.00
5151592020FinalJeterDerekGlove$30.00
5151632020FinalWalkerKarenPurse$500.00
5151562020FinalDoeJaneBox$10.50
5151612020FinalMertzEthelDress$100.00
5151602020FinalJordanMichaelSneakers$150.00
5151602020FinalJordanMichaelSneakers$150.00
Thanks!
 
Upvote 0
If you post your second table, I can probably show you how to do this in Power Query by joining the two tables. Fairly quick and simple to do.
Sorry for the double message, but I noticed I posted the second table with data already filled in. I'll repost both tables.

First table is the the workbook I am getting my data from

Client IDLast NameFirst NameItemCost
515155SmithJohnBook$1.50
515156DoeJaneBox$10.50
515158HayesCharlesChair$11.50
515158RodriguezAlexBaseball$5.00
515159JeterDerekGlove$30.00
515160JordanMichaelSneakers$150.00
515161MertzEthelDress$100.00
515162DraperDonSuit$1,000.00
515163WalkerKarenPurse$500.00

Second table is my report
Client IDYear of PurchaseSale TypeLast NameFirst NameItemCost
5151582020Final
5151622020Final
5151592020Final
5151632020Final
5151562020Final
5151612020Final
5151602020Final
5151602020Final

The vlookup formula I would use is =VLOOKUP(A2,[Book1]Sheet1!$A$2:$B$10,2,FALSE) to get the last name by match the client IDs, and then I'd run the formula again changing the column number to 3 for first name, 4 for item, and so on.

Thanks again!
 
Upvote 0
Using Power Query/Get and Transform which is located on the Data Tab,. Bring each table into PQ Editor and join them using the Mcode shown below.

Book2
ABCDEFG
1Client IDYear of PurchaseSale TypeLast NameFirst NameItemCost
25151582020FinalHayesCharlesChair11.5
35151582020FinalRodriguezAlexBaseball5
45151622020FinalDraperDonSuit1000
55151562020FinalDoeJaneBox10.5
65151592020FinalJeterDerekGlove30
75151632020FinalWalkerKarenPurse500
85151612020FinalMertzEthelDress100
95151602020FinalJordanMichaelSneakers150
105151602020FinalJordanMichaelSneakers150
Sheet3


Rich (BB code):
let
    Source = Table.NestedJoin(Table2, {"Client ID"}, Table1, {"Client ID"}, "Table1", JoinKind.LeftOuter),
    #"Expanded Table1" = Table.ExpandTableColumn(Source, "Table1", {"Last Name", "First Name", "Item", "Cost"}, {"Last Name", "First Name", "Item", "Cost"})
in
    #"Expanded Table1"
 
Upvote 0
I get the error "Expression.Error: A cyclic reference was encountered during evaluation." when I enter the Mcode. Let me detail the steps I take:

-I put both worksheets in one workbook, table them and named Table1 and Table2 respectively, save workbook under name "Book2"
-On the Excel ribbon I go to Data>New Query>Combine Queries>Launch Query Editor
-Under the Home tab of the PQ Editor, I go to New Source>File>Excel>Book2>Open
-The Navigator opens, I check "Select multiple items" and select Table1 and Table2>OK
-Then I go to View>Advanced Editor>Delete current code and replace with the code you provided>Done

This is where I receive the above error.
Thanks!
 
Upvote 0
Here is how I did it.
1. Loaded each table to PQ (note for table 2, I only loaded columns A,B and C)
2. Close and Loaded each to Connection only
3. Merged the two tables with the Mcode shown.
4. Close and Load to a Worksheet.

Your method should provide same results, but not sure why it isn't and what is causing the error message.
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,751
Members
448,989
Latest member
mariah3

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