formula to get the perfect matches between 2 rows

RAJESH1960

Banned for repeated rules violations
Joined
Mar 26, 2020
Messages
2,313
Office Version
  1. 2019
Platform
  1. Windows
Hello Guys,
I have this sheet where I have to get the Matches and Mismatches between Portal and Tally. Till now, I was using the formula shared by Mr. mikerickson, but today I noticed that when there are same or approximate amounts with a difference upto+1 or -1, which appear twice under the same GSTIN number, I was getting some mismatched amounts as matched. Earlier, when mikerickson shared the formula, I didn't share the columns of Invoice Number and Invoice Date as they were not always an exact match. Hope these columns are helpful in correcting the formula.
I need help to correct this formula and get the perfect matches. I am not sure but maybe a countif / s formula may solve the problem.
Sorry posted the wrong excel sheet. will post the right one in some time.
 
Last edited:

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
This is the workbook where I have matched the data of Portal and tally with Mikerickson's formula. As I said earlier that the formula is matching the multiple amounts under the same GSTIN number, I want it to match only one row of portal and tally. The rows marked yellow are not a match as shown in this sheet.

mikerickson's formula.xlsx
ABCDEFGHIJ
1LineAs perGSTIN of supplierXInvoice numberInvoice DateIntegrated Tax (₹)XXmikerickson's Formula
21PORTAL07XXXTB0431R1XD0000CR201900089322-05-2019900.00Matched
3108TALLY07XXXTB0431R1XD22-05-2019901.00Matched
42PORTAL07XXXTB0431R1XD0000CR201900116205-06-2019900.00Matched
53PORTAL07XXXTB0431R1XD0000CR201900116305-06-2019900.00Matched
64PORTAL07XXXTB0431R1XD0000CR201900116405-06-2019900.00Matched
7109TALLY07XXXTB0431R1XD05-06-2019899.00Matched
8110TALLY07XXXTB0431R1XD0000CR201900116305-06-2019900.00Matched
9111TALLY07XXXTB0431R1XD05-06-2019901.00Matched
105PORTAL07XXXTB0431R1XD0000CR201900180912-07-2019900.00Matched
11112TALLY07XXXTB0431R1XD12-07-2019900.00Matched
126PORTAL07XXXTB0431R1XD0000CR201900213126-07-2019900.00Matched
13113TALLY07XXXTB0431R1XD26-07-2019901.00Matched
147PORTAL07XXXTB0431R1XD0000CR201900227603-08-2019900.00Matched
15114TALLY07XXXTB0431R1XD03-08-2019899.50Matched
168PORTAL07XXXTB0431R1XD0000CR201900307619-09-2019900.00Matched
17115TALLY07XXXTB0431R1XD19-09-2019900.50Matched
189PORTAL07XXXTB0431R1XD0000CR201900312623-09-2019900.00Matched
19116TALLY07XXXTB0431R1XD312623-09-2019900.00Matched
2010PORTAL07XXXTB0431R1XD0000CR201900594628-02-2020900.00Matched
21117TALLY07XXXTB0431R1XD28-02-2020900.00Matched
2211PORTAL19XXECS5031Q1XVGST-065/19-2006-02-20201881.00Matched
23118TALLY19XXECS5031Q1XV6506-02-20201881.50Matched
2412PORTAL19XXECS5031Q1XVGST-052/19-2025-12-20192520.00Matched
2513PORTAL19XXECS5031Q1XVGST-053/19-2004-01-20202520.00Matched
26119TALLY19XXECS5031Q1XV5304-01-20202520.00Matched
2714PORTAL19XXECS5031Q1XVGST-057/19-2013-01-20202520.00Matched
28120TALLY19XXECS5031Q1XV5713-01-20202519.50Matched
29121TALLY27XXOFD3597R1XC44601-01-20207520.90Matched
30122TALLY27XXOFD3597R1XC44701-01-20207521.00Matched
31123TALLY27XXOFD3597R1XC44801-01-20207522.00Matched
32124TALLY27XXOFD3597R1XC44401-01-20207521.45Matched
33125TALLY27XXOFD3597R1XC44501-01-20207521.45Matched
34126TALLY27XXOFD3597R1XC44301-01-20207521.50Matched
3515PORTAL27XXOFD3597R1XCDEI-00438/19-2029-12-20197521.58Matched
3616PORTAL27XXOFD3597R1XCDEI-00443/19-2030-12-20197521.58Matched
3717PORTAL27XXOFD3597R1XC44430-12-20197521.58Matched
3818PORTAL27XXOFD3597R1XCDEI-00445/19-2030-12-20197521.58Matched
3919PORTAL27XXOFD3597R1XCDEI-00446/19-2031-12-20197521.58Matched
4020PORTAL27XXOFD3597R1XCDEI-00447/19-2031-12-20197521.58Matched
4121PORTAL27XXOFD3597R1XC44831-12-20197521.58Matched
Matched
Cell Formulas
RangeFormula
J2:J41J2=IF(MATCH(1,((ABS(G2-$G$2:$G$23200)<=1))*(C2=$C$2:$C$23200)*(B2<>$B$2:$B$23200),0),"Matched","")
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Hello again,
As this query is connected to this post, I am posting it here again with some data and brief explanation.
I am not sure which formula to get the expected result, but I have tried Index and Match but not countifs in the sample data.
Loading Google Sheets
 
Upvote 0
I would not want to maintain this formula, but this appears to work. The only discrepancy between the formula results and your expected results are the orange cells, and I believe the order in this case is arbitrary. The formula will tag the first (from the top) as "Matched", while any below it that have no mate will be tagged "Not Found".
MrExcel_20220525_Rajesh_Match using index match or Countifs.xlsx
ABCDEFGHIJK
1LineAs PerGSTIN of supplierNameInvoice numberInvoice DateIntegrated TaxCentral TaxState/UTExpected ResultNew Formula
2
31PORTAL06XXXCR0846G1RN17609-02-20173060.000.000.00MatchedMatched
42PORTAL06XXXCR0846G1RN17709-02-20173060.000.000.00Not FoundNot Found
53PORTAL06XXXCR0846G1RN8008-04-20171530.000.000.00MatchedMatched
64PORTAL06XXXCR0846G1RN207-05-20171530.000.000.00MatchedMatched
75PORTAL05XXBCN7151P1R517320014426-07-201734125.000.000.00MatchedMatched
86PORTAL05XXBCN7151P1R517320014326-07-201773990.000.000.00MatchedMatched
97PORTAL05XXBCN7151P1R517320127711-09-201734125.000.000.00Not FoundNot Found
108PORTAL03XXXCH5841B1R8S-19612-11-20171530.000.000.00MatchedMatched
119PORTAL05XXBCN7151P1R517320169015-12-201752668.000.000.00MatchedMatched
1210PORTAL03XXXCH5841B1R8G-62622-02-201854900.000.000.00MatchedMatched
1311PORTAL03XXXCH5841B1R8S-29926-02-20181530.000.000.00Not FoundNot Found
1412PORTAL03XXXCH5841B1R8S-30827-02-2018990.000.000.00MatchedMatched
1513PORTAL03XXXCH5841B1R8S-35928-03-20182700.000.000.00MatchedMatched
1614PORTAL03XXXCH5841B1R8G-5301-04-20188820.000.000.00Not FoundMatched
1715PORTAL03XXXCH5841B1R8G-66503-07-201826190.000.000.00MatchedMatched
1816PORTAL03XXXCH5841B1R8G-53101-12-20188820.000.000.00MatchedNot Found
191TALLY05XXBCN7151P1R508-01-201734125.000.000.00MatchedMatched
202TALLY05XXBCN7151P1R517320014308-01-201773990.000.000.00MatchedMatched
213TALLY06XXXCR0846G1RN26410-01-201752668.000.000.00Not FoundNot Found
224TALLY06XXXCR0846G1RN09-02-20173059.500.000.00MatchedMatched
235TALLY06XXXCR0846G1RN8008-04-20171530.500.000.00MatchedMatched
246TALLY06XXXCR0846G1RN08-04-20171531.000.000.00MatchedMatched
257TALLY06XXXCR0846G1RN07-05-20171530.000.000.00Not FoundNot Found
268TALLY05XXBCN7151P1R511-09-20179360.000.000.00Not FoundNot Found
279TALLY05XXBCN7151P1R517320169015-12-201752668.000.000.00MatchedMatched
2810TALLY03XXXCH5841B1R803-01-2018990.000.000.00MatchedMatched
2911TALLY03XXXCH5841B1R803-01-20181530.000.000.00MatchedMatched
3012TALLY03XXXCH5841B1R8G062603-01-201854899.500.000.00MatchedMatched
3113TALLY03XXXCH5841B1R8G062703-01-201854900.500.000.00Not FoundNot Found
3214TALLY03XXXCH5841B1R828-03-20182700.000.000.00MatchedMatched
3315TALLY03XXXCH5841B1R8G066503-07-201826189.500.000.00MatchedMatched
3416TALLY03XXXCH5841B1R8G053101-12-20188820.500.000.00MatchedMatched
Matched
Cell Formulas
RangeFormula
K3:K34K3= IF(SUM( (ABS(G3-$G$3:$G$34)<=1) * (C3=$C$3:$C$34) * ("Portal"=$B$3:$B$34)) = SUM( (ABS(G3-$G$3:$G$34)<=1) * (C3=$C$3:$C$34) * ("Tally"=$B$3:$B$34) ), "Matched", IF(SUM( (ABS(G3-$G$3:$G$34)<=1) * (C3=$C$3:$C$34) * ("Portal"=$B$3:$B$34)) > SUM( (ABS(G3-$G$3:$G$34)<=1) * (C3=$C$3:$C$34) * ("Tally"=$B$3:$B$34) ), IF(SUM( (ABS(G3-$G$3:$G3)<=1) * (C3=$C$3:$C3) * (B3=$B$3:$B3) ) <= SUM( (ABS(G3-$G$3:$G$34)<=1) * (C3=$C$3:$C$34) * ("Tally"=$B$3:$B$34) ), "Matched", "Not Found"), IF(SUM( (ABS(G3-$G$3:$G$34)<=1) * (C3=$C$3:$C$34) * ("Tally"=$B$3:$B$34) ) > SUM( (ABS(G3-$G$3:$G$34)<=1) * (C3=$C$3:$C$34) * ("Portal"=$B$3:$B$34) ), IF(SUM( (ABS(G3-$G$3:$G3)<=1) * (C3=$C$3:$C3) * (B3=$B$3:$B3) ) <= SUM( (ABS(G3-$G$3:$G$34)<=1) * (C3=$C$3:$C$34) * ("Portal"=$B$3:$B$34) ),"Matched", "Not Found"))))
 
Upvote 0
whoopee!! That is one of the biggest formula I have seen. You got the maximum number of Matches possible. That is 90% of the work done and it will save a lot of time when matching huge data base with 20000 or more rows. I can, manually check the rest of the data to check the not found.
You are right about this. I couldn't get the right words to explain what you mentioned in the below message. For that I will sort the data by date and then enter the formula. That way it will become more accurate. Right.
The formula will tag the first (from the top) as "Matched", while any below it that have no mate will be tagged "Not Found".

There is but one problem. The formula should not show not found rows as Matched rows in any case. In this case you formula shows rows 2, 3 and 21 as matches whereas it has to show only 2 and 21 or 3 and 21. There has to be always one set of rows to match. In this case it is 3 rows. If you can correct this, it would just be great.
 
Upvote 0
I can't view your row 2 values. In your case, it is rows 3, 4 and 22
 
Upvote 0
If you remember I had the same problem a year ago. You just added +1 in the formula and solved it. I assume it was for if common amounts take one and again if common amounts take the next one.
Rich (BB code):
=IF(M2="","",IFERROR(INDEX($A$3:$I$2000,AGGREGATE(15,6,(ROW($C$3:$C$2000)-ROW($C$2))/($C$3:$C$2000=$M3),INT((COLUMNS($O3:P3)+1)/2)),9),""))
But this was for a different project which was completely different.
 
Upvote 0
I don't understand your point. My formula matches your expected results except for rows 16 and 18, and I believe it is arbitrary which of those would be labeled first as matched. Can you explain why you believe there is an issue with 3,4, and 22? 3 matches 22 and that leaves 4 unmatched...therefore "Not found". Those results appear to be consistent with your expected results too.
 
Upvote 0
Line 3 and 22 should show as matched and line 4 should be Not found. If you copy the matched amounts rows to a different sheet and sub total Portal and Tally you will find the difference.
I will send the sub total sheet in some time.
 
Upvote 0

Forum statistics

Threads
1,216,098
Messages
6,128,812
Members
449,468
Latest member
AGreen17

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