Comments on: Excel Question: VLOOKUP and beyond?
http://ask.metafilter.com/274478/Excel-Question-VLOOKUP-and-beyond/
Comments on Ask MetaFilter post Excel Question: VLOOKUP and beyond?Thu, 15 Jan 2015 09:31:56 -0800Thu, 15 Jan 2015 09:38:55 -0800en-ushttp://blogs.law.harvard.edu/tech/rss60Question: Excel Question: VLOOKUP and beyond?
http://ask.metafilter.com/274478/Excel-Question-VLOOKUP-and-beyond
How can I combine these two tabs of data in Excel using VLOOKUP and/or some other function? <br /><br /> I have two tabs; there are a number of columns on each sheet so I'm only sharing the ones that I think are relevant below. <br>
<br>
The first tab has data for appointments, one line for each date each person had an appointment (with unique ID for each person&date). Some people have more than one appointment, others do not.<br>
<br>
Smith,1/1/2015, Smith01012015<br>
Smith,1/12/2015, Smith01122015<br>
Kringle, 1/4/2015, Kringle01042015<br>
Jones, 1/2/2015, Jones01022015<br>
Jones, 1/3/2015, Jones01032015<br>
<br>
<br>
The second tab has data for payments, one line for each thing billed on each date each person had an appointment. Some people have multiple things billed on each date and some only have one.<br>
<br>
Smith, 1/1/2015, Smith01012015, $300<br>
Smith, 1/1/2015, Smith01012015, $400<br>
Smith, 1/1/2015, Smith01012015, $25<br>
Smith,1/12/2015, Smith01122015, $500<br>
Smith,1/12/2015, Smith01122015, $50<br>
Kringle, 1/4/2015, Kringle01042015, $85<br>
Jones, 1/2/2015, Jones01022015, $600<br>
Jones, 1/2/2015, Jones01022015, $10<br>
Jones, 1/3/2015, Jones01032015, $325<br>
<br>
What is the best way to pull together this data into one tab that has the total payments for each date each person was seen? Desired final product will look like this:<br>
<br>
Smith,1/1/2015, Smith01012015, $725<br>
Smith,1/12/2015, Smith01122015, $550<br>
Kringle, 1/4/2015, Kringle01042015, $85<br>
Jones, 1/2/2015, Jones01022015, $710<br>
Jones, 1/3/2015, Jones01032015, $325<br>
<br>
I used a VLOOKUP to pull the $ data from tab 2 to tab 1, but it only would pick up the first line for each person/date. Other than the person's name and the appointment date, there is no other field that is on both tabs.<br>
<br>
I thank you for any help you can provide.post:ask.metafilter.com,2015:site.274478Thu, 15 Jan 2015 09:31:56 -0800ThePinkSuperheroexcelvlookupdataresolvedBy: jeather
http://ask.metafilter.com/274478/Excel-Question-VLOOKUP-and-beyond#3983288
Pivot tables are (always) the answer.<br>
<br>
You don't need tab one at all, just make a pivot table out of tab two. I'd probably concatenate the first 3 columns into one, so you are making the table out of two columns -- they will need header lines, btw -- but it's exactly the thing you use a pivot table for.comment:ask.metafilter.com,2015:site.274478-3983288Thu, 15 Jan 2015 09:38:55 -0800jeatherBy: brainmouse
http://ask.metafilter.com/274478/Excel-Question-VLOOKUP-and-beyond#3983294
You almost certainly want a pivot table. Ignore Tab 1 entirely, create a Pivot Table on the Tab 2 data where the rows are Column 3 from Tab 2, and the values is the money column. That should work fine.<br>
<br>
The other option -- and this is not ideal -- is to use sumifs. The formula would go in column 4 on Tab 1 and look like:<br>
=sumifs(MoneyColumnTab2,PersonColumnTab2,CurrentRowPersonColumnTab1,DateColumnTab2,CurrentRowDateColumnTab1)<br>
<br>
which translates to: give me a sum of MoneyColumnTab2, if PersonColumnTab2 is equal to the current value of Person in this row, and if DateColumnTab2 is equal to the current value of Date in this row. You could also just do it on the concatenated column instead of doing those 2 columns separately.<br>
<br>
Sumifs are pretty processor intensive and nowhere near as neat or reliable as a pivot table, so try to make the pivot table work, it's the desired way to do this.comment:ask.metafilter.com,2015:site.274478-3983294Thu, 15 Jan 2015 09:43:52 -0800brainmouseBy: ThePinkSuperhero
http://ask.metafilter.com/274478/Excel-Question-VLOOKUP-and-beyond#3983295
Ugh, I forgot to mention one thing: tab 1 and 2 don't have all the same rows. All of tab 2 is on tab 1, but there's extra rows on tab 1 that aren't on tab 2. A pivot table would be the answer if both tabs had all the same rows, but where do I go from here?comment:ask.metafilter.com,2015:site.274478-3983295Thu, 15 Jan 2015 09:44:51 -0800ThePinkSuperheroBy: jeather
http://ask.metafilter.com/274478/Excel-Question-VLOOKUP-and-beyond#3983303
What kind of data is on tab 1 that isn't on tab 2? <br>
<br>
Is this something you need to do once or regularly?comment:ask.metafilter.com,2015:site.274478-3983303Thu, 15 Jan 2015 09:48:33 -0800jeatherBy: ThePinkSuperhero
http://ask.metafilter.com/274478/Excel-Question-VLOOKUP-and-beyond#3983309
Sorry, I got it backwards- there are rows on tab 2 that aren't on tab 1. I need data from both tabs but only for the rows on tab 1. So I need to filter out all the rows that aren't on both tabs. <br>
<br>
Right now, this is a one-off task.comment:ask.metafilter.com,2015:site.274478-3983309Thu, 15 Jan 2015 09:52:38 -0800ThePinkSuperheroBy: jeather
http://ask.metafilter.com/274478/Excel-Question-VLOOKUP-and-beyond#3983311
So make the pivot table from tab 2 (using the unique name/date code), then vlookup from tab 1 into the pivot table.comment:ask.metafilter.com,2015:site.274478-3983311Thu, 15 Jan 2015 09:53:44 -0800jeatherBy: brainmouse
http://ask.metafilter.com/274478/Excel-Question-VLOOKUP-and-beyond#3983334
I might do a vlookup onto Tab 2 that was something like =if(iserror(vlookupformula),0,1) -- which will return a 0 if the vlookup gives an error (so the row isn't on tab 1), and a 1 if the vlookup doesn't (so the row is on tab 1) -- then put that column as a filter into your pivot table and only look at the 1s.comment:ask.metafilter.com,2015:site.274478-3983334Thu, 15 Jan 2015 10:11:20 -0800brainmouseBy: ThePinkSuperhero
http://ask.metafilter.com/274478/Excel-Question-VLOOKUP-and-beyond#3983338
Ah ha! jeather got it! Pivot table, then the VLOOKUP. You are all the best. I'm not giving you the credit when I impress my boss, though :Dcomment:ask.metafilter.com,2015:site.274478-3983338Thu, 15 Jan 2015 10:14:50 -0800ThePinkSuperheroBy: Gee Your Hair Smells Terrific
http://ask.metafilter.com/274478/Excel-Question-VLOOKUP-and-beyond#3983468
If you're feeling adventurous, SUMIFS would have also been your friend here. <br>
<br>
Create a new tab, then copy/paste your list of names and dates (but not amounts). Use the Data->Remove Duplicates function to give you a list of unique names & Date combos. Finally, use the SUMIFS function to return the sum of lines where the names and dates match your selection criteria.comment:ask.metafilter.com,2015:site.274478-3983468Thu, 15 Jan 2015 12:20:31 -0800Gee Your Hair Smells Terrific