Comparing two tables for changes

Dnm88

New Member
Joined
Aug 10, 2020
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hi all!

I have two tables that I need to compare. The second table is a monthly update to the first one. It consists of various columns, some of them stay the same (like trade names, ingredients), some of them differ (price changes, manufacturer changes) from month to month. On top of that, each entry is assigned one of three possible categories (let's call them A, B or C) and some entries move from one category to another when it gets updated every month.

The lists are technically ordered alphabetically, but the order changes from month to month as new entries are added and some old ones are removed.

It would be ideal if there was a way of:

- listing all the entries that changed from one category to another (from B to C for example) whilst making sure that all the other details of the entry match perfectly (like the trade name and ingredients)

- listing all the new entries

- listing all the removed entries


I tried playing with =CONCATENATE to extract the information from relevant cells and then used =VLOOKUP to compare the entries between those tables, plus another column that returns TRUE or FALSE based on whether the entries match. Unfortunately, this doesn't seem to work 100%, feels a bit clunky and doesn't achieve all the points I listed above.

Is there another way of doing it without having to resort to addons and plugins? :)
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Hi DNM88,

This may go some way to satisfy your request:

DNM88.xlsx
ABCDEF
1ProductCategoryTrade NameIngredientsPriceManufacturer
2DD098CDuck DownFeathers$28.00Quack Inc
3FIG003BFiggy PuddingHoney, figs$12.00Baker Bros
4TR999CFour CandlesFork handles$43.00Ronnieton
5GIN001AMothers RuinGin$23.00Stiller
6TH773AToad in the HoleSausage, batter$12.00Toadstool Ltd
7
OldMonth


DNM88.xlsx
ABCDEFGHIJKL
1ProductCategoryTrade NameIngredientsPriceManufacturerChanged CategoryTrade NameIngredientsPriceManufacturer
2DD098CDuck DownFeathers$28.00Quack Inc     
3GIN001BMothers RuinGin$55.00Alcool IncGIN001  ChangedChanged
4BK042ABees KneesHoney$233.00BuzzCorp     
5FIG003AFiggy PuddingHoney, nuts, figs$12.00Baker BrosFIG003 Changed  
6CM032BCats MeowPurrs, licks$22.00Kitty Inc     
7     
NewMonth
Cell Formulas
RangeFormula
H2:H7H2=IF(IFERROR(INDEX(OldMonth!$B$2:$B$9999,MATCH(A2,OldMonth!$A$2:$A$9999,0)),B2)<>B2,NewMonth!A2,"")
I2:L7I2=IF($H2="","",IF(C2<>INDEX(OldMonth!C$2:C$9999,MATCH($A2,OldMonth!$A$2:$A$9999,0)),"Changed",""))


DNM88.xlsx
ABCDEFGHIJKLMNO
1New ProductsRemoved Products
2New RowProductCategoryTrade NameIngredientsPriceManufacturerRemoved RowProductCategoryTrade NameIngredientsPriceManufacturer
33BK042ABees KneesHoney233BuzzCorp3TR999CFour CandlesFork handles43Ronnieton
45CM032BCats MeowPurrs, licks22Kitty Inc5TH773AToad in the HoleSausage, batter12Toadstool Ltd
5              
Results
Cell Formulas
RangeFormula
A3:A5A3=IFERROR(AGGREGATE(15,6,ROW(NewMonth!$A$2:$A$9999)-ROW(NewMonth!$A$1)/((ISNA(MATCH(NewMonth!$A$2:$A$9999,OldMonth!$A$2:$A$9999,0)))*(NewMonth!$A$2:$A$9999<>"")),ROW()-ROW($A$2)),"")
B3:G5B3=IF($A3="","",INDEX(NewMonth!A:A,$A3+1))
I3:I5I3=IFERROR(AGGREGATE(15,6,ROW(OldMonth!$A$2:$A$9999)-ROW(OldMonth!$A$1)/((ISNA(MATCH(OldMonth!$A$2:$A$9999,NewMonth!$A$2:$A$9999,0)))*(OldMonth!$A$2:$A$9999<>"")),ROW()-ROW($A$2)),"")
J3:O5J3=IF($I3="","",INDEX(OldMonth!A:A,$I3+1))
 
Upvote 0
Hi Toadstool!

That’s great, thank you for your help! Sorry for a delay, I was away from the office so only got a chance to try it today.

I was playing with the first for formula you provided so that if it detects that the product changed its category it then returns the old value so that I can compare it easily with the new value. So ideally I’d have one column that tells me if the category has changed and then another column to tell me what it changed from, as I am ultimately after isolating the ones that changed from only specific categories to a different set of specific categories, so that I can update those categories on another system (hope that makes sense?). Unfortunately, the results of my changed formula don’t seem to be what I was after, although I have a feeling I might’ve mixed something up. I tried figuring out how the formula works based on the example you provided, but not 100% I got it all right.

This is what I tried:

=IF(IFERROR(INDEX(OldMonth!$L$2:$L$9999,MATCH(B2,OldMonth!$B$2:$B$9999,0)),"")<>B2,OldMonth!L2,"")

Column B contains product name, Column L contains category.

Really grateful fro your help!
 
Upvote 0
Hi Dnm88,

My test data just put the headings in the sequence you mentioned them. If you can use XL2BB or just an image of your headings then I can give a more appropriate example.

Here's the NewMonth tab with modified comparison columns (the other 2 tabs have not changed at all). If a Category has changed then it reports the old value for Category. If the Category has changed it then checks the other columns for changes and reports the old value.
NOTE: It only checks for other changes if the Category has changed, e.g. DD098 Duck Down had Ingredients of "Feathers" and now has Ingredients of "Some Feathers" but is not reported because the Category has not changed).

DNM88-2.xlsx
ABCDEFGHIJKLM
1ProductCategoryTrade NameIngredientsPriceManufacturerChanged CategoryOld CategoryOld Trade NameOld IngredientsOld PriceOld Manufacturer
2DD098CDuck DownSome Feathers$28.00Quack Inc      
3GIN001BMothers RuinGin$55.00Alcool IncGIN001A  23Stiller
4BK042ABees KneesHoney$233.00BuzzCorp      
5FIG003AFiggy PuddingHoney, nuts, figs$12.00Baker BrosFIG003B Honey, figs  
6CM032BCats MeowPurrs, licks$22.00Kitty Inc      
7     
NewMonth
Cell Formulas
RangeFormula
J2:M6J2=IF($H2="","",IF(C2<>INDEX(OldMonth!C$2:C$9999,MATCH($A2,OldMonth!$A$2:$A$9999,0)),INDEX(OldMonth!C$2:C$9999,MATCH($A2,OldMonth!$A$2:$A$9999,0)),""))
J7:M7J7=IF($H7="","",IF(C7<>INDEX(OldMonth!C$2:C$9999,MATCH($A7,OldMonth!$A$2:$A$9999,0)),"Changed",""))
I2:I6I2=IF($H2="","",INDEX(OldMonth!B$2:B$9999,MATCH($A2,OldMonth!$A$2:$A$9999,0)))
H2:H7H2=IF(IFERROR(INDEX(OldMonth!$B$2:$B$9999,MATCH(A2,OldMonth!$A$2:$A$9999,0)),B2)<>B2,NewMonth!A2,"")
 
Upvote 0
Hi Toadstool!

I've included an example of my table layout below:

Sl #Trade NameFormPack SizePharmacy PricePublic PriceActive IngredientStrengthCompanySourceAgentCategory
1(GI) 0.9% W/V SODIUM CHLORIDE ***Isotonic Solution for Irrigation1000ml LDPE Bottle8,7410,50Sodium Chloride0.9% w/vABCT LLCABCDRUG STORECD
2(GI) 0.9% W/V SODIUM CHLORIDE ***Isotonic Solution for Irrigation500ml LDPE Bottle4,375,00Sodium Chloride0.9% w/vADT LLCCDAXDA DRUG STOREP
30.2% CIPROFLOXACIN in 0.9% W/V SODIUM CHLORIDE INJECTION USPInfusion/Solution for100ml Plastic Bag16,8820,50Ciprofloxacin (as lactate)2mg/mlXAT PHARMAQADSPHARMA STORESPOM



I had some luck with listing new and removed products (for some reason still had some false positive results), I couldn't get this formula to work:

H2=IF(IFERROR(INDEX(OldMonth!$B$2:$B$9999,MATCH(A2,OldMonth!$A$2:$A$9999,0)),B2)<>B2,NewMonth!A2,"")

Keep getting an error message both before and after replacing the column letters :(

Based on the layout of my tables my goal is to:

- ideally be able to list all the products (based on the trade name column) that have changed categories and be able to see both the old and new one for comparison. One potential issue is that the Trade Name column can have minor differences (like added asterisks for example) from month to month, even though it's exactly the same product. Alternatively, if I could make the formula search by the Active Ingredient column values instead and provide me with a list of ingredients that changed category (with matching trade names next to it) - this would be fine as well.

- be able to list all the additions/removals, which your formula helped with and I'm guessing the false positive results came from those minor differences in the Trade Name column

Hope this makes it a bit more clear!
 
Upvote 0
Hi Dnm88,

I've changed my examples to use your column headings.

If a Category changes and the only difference between Trade Names is the number of "*" then I've used SUBSTITUTE to remove all asterisks for the comparison, so it should only report if something else changed.

Here are my 3 tabs again in the new formats:

DNM88-3.xlsx
ABCDEFGHIJKL
1Sl #Trade NameFormPack SizePharmacy PricePublic PriceActive IngredientStrengthCompanySourceAgentCategory
21(GI) 0.9% W/V SODIUM CHLORIDE ***Isotonic Solution for Irrigation1000ml LDPE Bottle8.7410.5Sodium Chloride0.9% w/vABCT LLCABCDRUG STORECD
32(GI) 0.9% W/V SODIUM CHLORIDE ***Isotonic Solution for Irrigation500ml LDPE Bottle4.375Sodium Chloride0.9% w/vADT LLCCDAXDA DRUG STOREP
430.2% CIPROFLOXACIN in 0.9% W/V SODIUM CHLORIDE INJECTION USPInfusion/Solution for100ml Plastic Bag16.8820.5Ciprofloxacin (as lactate)2mg/mlXAT PHARMAQADSPHARMA STORESPOM
56(GI) 1.2% DrugidonTabletx 22$44.00$88.00Drugidone88%DownyADDCarefulCD
65XanaxCapsulex 50$55.00$99.00Sleepioxide2mg/mlDownyADDCarefulCD
7
OldMonth


DNM88-3.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXY
1Sl #Trade NameFormPack SizePharmacy PricePublic PriceActive IngredientStrengthCompanySourceAgentCategoryChanged CategoryOld CategoryOld Trade NameOld FormOld Pack SizeOld Pharmacy PriceOld Public PriceOld Active IngredientOld StrengthOld CompanyOld SourceOld Agent
21(GI) 0.9% W/V SODIUM CHLORIDE ********Isotonic Solution for Irrigation1000ml LDPE Bottle8.7410.50Sodium Chloride0.9% w/vABCT LLCABCDRUG STOREXX1CD          
32(GI) 0.9% W/V SODIUM CHLORIDE ***Isotonic Solution for Irrigation500ml LDPE Bottle4.375.00Sodium Chloride0.9% w/vADT LLCCDAXDA DRUG STOREP            
46(GI) 1.2% DrugidonTabletx 2244.0088.00Drugidone0.88DownyADDCarefulCD            
541% OlanzapineTabletx 5022.0044.00Sulphobeneazo Acid0.12Hallucino CorpADDCarefulX            
65Xanax ExtraCapsulex 555.00255.00Sleepioxide2mg/mlDownyADDCarefulY5CDXanax x 50 99.00     
7            
NewMonth
Cell Formulas
RangeFormula
N2:N7N2=IF(IFERROR(INDEX(OldMonth!$L$1:$L$10001,MATCH(A2,OldMonth!$A$1:$A$10001,0)),L2)<>L2,NewMonth!A2,"")
O2:O7O2=IF($N2="","",INDEX(OldMonth!L$1:L$10001,MATCH($A2,OldMonth!$A$1:$A$10001,0)))
P2:P7P2=IF($N2="","",IF(SUBSTITUTE(B2,"*","")<>SUBSTITUTE(INDEX(OldMonth!B$1:B$10001,MATCH($A2,OldMonth!$A$1:$A$10001,0)),"*",""),INDEX(OldMonth!B$1:B$10001,MATCH($A2,OldMonth!$A$1:$A$10001,0)),""))
Q2:Y7Q2=IF($N2="","",IF(C2<>INDEX(OldMonth!C$1:C$10001,MATCH($A2,OldMonth!$A$1:$A$10001,0)),INDEX(OldMonth!C$1:C$10001,MATCH($A2,OldMonth!$A$1:$A$10001,0)),""))


DNM88-3.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAA
1New ProductsRemoved Products
2New RowSl #Trade NameFormPack SizePharmacy PricePublic PriceActive IngredientStrengthCompanySourceAgentCategoryRemoved RowSl #Trade NameFormPack SizePharmacy PricePublic PriceActive IngredientStrengthCompanySourceAgentCategory
3441% OlanzapineTabletx 502244Sulphobeneazo Acid0.12Hallucino CorpADDCarefulX330.2% CIPROFLOXACIN in 0.9% W/V SODIUM CHLORIDE INJECTION USPInfusion/Solution for100ml Plastic Bag16.8820.5Ciprofloxacin (as lactate)2mg/mlXAT PHARMAQADSPHARMA STORESPOM
4                          
5                          
Results
Cell Formulas
RangeFormula
A3:A5A3=IFERROR(AGGREGATE(15,6,ROW(NewMonth!$A$2:$A$9999)-ROW(NewMonth!$A$1)/((ISNA(MATCH(NewMonth!$A$2:$A$9999,OldMonth!$A$2:$A$9999,0)))*(NewMonth!$A$2:$A$9999<>"")),ROW()-ROW($A$2)),"")
B3:M5B3=IF($A3="","",INDEX(NewMonth!A:A,$A3+1))
O3:O5O3=IFERROR(AGGREGATE(15,6,ROW(OldMonth!$A$2:$A$9999)-ROW(OldMonth!$A$1)/((ISNA(MATCH(OldMonth!$A$2:$A$9999,NewMonth!$A$2:$A$9999,0)))*(OldMonth!$A$2:$A$9999<>"")),ROW()-ROW($O$2)),"")
P3:AA5P3=IF($O3="","",INDEX(OldMonth!A:A,$O3+1))
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,720
Members
448,986
Latest member
andreguerra

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