Merging/comparing multiple sheets without duplicates and grabbing highest values?

Hi, I’m trying to help a friend who has multiple spreadsheets that need to be merged and compared into one sheet. Here’s the basic idea of what needs to done.

There are two sheets that item names and number of items. Column A would have the name and column B would be the number of the item from column A. It would be ideal if there was a way to look at the column A item between sheets and list all items without duplicating them and then in column B only put the highest number between the two sheets.

So, if sheet 1 had apples, oranges, and pears in column A and sheet 2 had apples, kiwis, and oranges in column A, a sheet 3 would be generated that listed apples, kiwis, oranges, and pears in column A. 

It would also compare the values in column B would be number of fruit and then output the greatest value between the two in sheet 3’s column B. For example, if sheet 1 had 2 listed in column B after apples in column A and sheet 2 had 4 list in its column B, then sheet 3 would list 4 it’s column B.

Hopefully, this makes sense. My friend is not experienced with Excel and this was kind of dumped on them. I’m a little more computer savvy, but only used Excel a bit in the past and only worked with some basic formulas. Any help would great. Thanks!

MacBook Pro 15″, macOS 10.15

Posted on Dec 28, 2020 8:47 PM

Reply
15 replies

Dec 28, 2020 11:17 PM in response to Circleof05ths

Hi Circleof05ths,


This screen shot shows the three tables on one Sheet (Tab). The formulas will work between different sheets within the one document.



Formulas in Table 3 ( and fill down). The IFERROR function inserts zero if there is no match.

B2 IFERROR(INDEX(Table 1::B,MATCH($A2,Table 1::A,0)),0)

C2 IFERROR(INDEX(Table 2::B,MATCH($A2,Table 2::A,0)),0)

D2 MAX(B2,C2)


When all is working, select and copy column D, then Menu > Edit > Paste Formula Results.

Then you can delete columns B and C in Table 3.


Regards,

Ian.

Jan 3, 2021 6:30 PM in response to Circleof05ths

Hi Circ'


"something is wrong with the formula"


True, and the error message tells you what is wrong with it:

“This formula can’t reference it’s own cell, or depend on another formula that references this cell.”

At first glance, it appears that a self reference error referencing the cell containing the formula may override the IFERROR instruction to place a zero in the cell.


MATCH says: 'Get the value from cell A2' (of 'this table')

For the copy of the formula that is in cell A2 of this table, that is a self-reference, and the cause of the error.

The value in cell A2 is created by the formula in A2, but the formula depends on that value to create that value, which Numbers won't tolerate.


"The other columns return zero when I put the formulas in."

As they should. MATCH in these cells depends on the value in A2 as a value to search for in column A of Table 1. As there is no value in A2 of 'this table', the formula is apparently finding the empty cells at the bottom of Column A of Table 1, and returning a 0 numeric value of the content of that cell.


In Ian's example, the formula you used is in the selected cell (B2 of Table 3) shown in his screen shot, and references cell A2 of that table to get the value to search for. The values in column A of Table 3 appear to have been entered from the keyboard, as there's no formula shown for creating them.


Given the number of distinct fruit names involved, I suspect Ian copies the list from one of Table 1 or Table 2, then added the distinct names from Table 2.


Bottom line:

  • Delete the formula in A2 of your copy of Table 3 (and any copies of that formula in the rst of the cells in column A of that table. (Leave the copies in other columns in place.)
  • Copy the Column A list from either Table 1 or Table 2, select A2 of Table 3 and Paste.
  • Add the names from column A of Table 2 that are NOT present on Table 1.


Your table should then be working.


Regards,

Barry



Jan 3, 2021 6:53 PM in response to Barry

Hi Barry,

Thanks for the reply. Yes, I figured out the problem was in the fruit column A. However, entering them manually, won’t work as there’s about 12 different tables and about 160 names in the column A for the project I’m working on.

Is there a formula to compare the column A fruits between Table 1 and Table and get the result in Table 3 without having enter them manually?

Jan 4, 2021 2:18 AM in response to Circleof05ths

You don't need to struggle with formulas to do this. You can do it with a few clicks and copy-pastes.


Copy-paste the values in one table into the bottom of the other so all the data is in one table. Don't worry about duplicates.



Right-click in the fruit column of the table with all the data and choose Add Category for ...:




Click the 'gear' icon in the column with the quantities and choose Maximum.



Collapse the Peer Groups:





Select the visible cells, command-c to copy to clipboard, and in another existing table Edit > Paste and Match Style.






Giving you something like this:



Delete any extra columns in the middle.


This all should take you less than a minute, and you're done


SG

Jan 4, 2021 9:20 AM in response to SGIII

Thanks for the help. I’ll try this out. I wanted to do this as a formula so I could set up a template for myself and have it automated, but this is a good back up.

Formula-wise, I was able to get to the point where it would compare the fruit columns of two tables and put the common ones in a third table. However, it would error out if there were unique ones. So, I haven’t figured out how to compare two items and if they are different, give each one a listing.

Jan 4, 2021 4:47 PM in response to Circleof05ths

Circleof05ths wrote:

Thanks for the help. I’ll try this out. I wanted to do this as a formula so I could set up a template for myself and have it automated, but this is a good back up.


Sometimes trying to over-automate with formulas doesn't make sense. If you can do something in a few seconds with a few clicks and copy-pastes, using an interface Apple designed to make tasks like this easier than with formulas, why go through lot of pain to set up formulas to do the same thing? That only makes sense if you have to constantly update every few seconds, which doesn't seem to be the case here.


SG



Feb 6, 2021 5:38 PM in response to SGIII

I've been using this with no problems, but wanted to see if there was a way to have a subtotal instead of the maximum in the quantity column. For example, Oranges from the above table, are listed with a 3 and 6 in the quantity column. Instead of get the 6 returned as the maximum, I'd like the 3 and 6 values be added together and return a 9. I tried to change max to the subtotal, but it just returns zero. Any way to do this? Thanks for all the help, it's been a life saver!

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Merging/comparing multiple sheets without duplicates and grabbing highest values?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.