Merge two Excel tables Based on matching data in Columns - excel

I've been working on a excel problem, that I need to find an answer for I'll explain it below.
I've Table01 with the Columns :
Group No
Name
Price
I've Table02 with the columns:
Group No
City
Code
I've merged two tables of Table01 & Table02 as shown in the Image03 , But without order.
But,as you see Group No Column is similar in both tables.
What I need is to get the matching rows of Table01 & 02 considering 'Group No' Column.
The Final result is to be seen as the final image.
Is there a way to do this with excel functions ?
Thank You!

Put the table in the second image on Sheet2, columns D to F.
In Sheet1, cell D2 use the formula
=iferror(vlookup($A2,Sheet2!$D$1:$F$100,column(A1),false),"")
copy across and down.
Edit: here is a picture. The data is in two sheets. On Sheet1, enter the formula into cell D2. Then copy the formula across to F2 and then down as many rows as you need.

Teylyn's answer worked great for me, but I had to modify it a bit to get proper results. I want to provide an extended explanation for whoever would need it.
My setup was as follows:
Sheet1: full data of 2014
Sheet2: updated rows for 2015 in A1:D50,
sorted by first column
Sheet3: merged rows
My data does not have a header row
I put the following formula in cell A1 of Sheet3:
=iferror(vlookup(Sheet1!A$1;Sheet2!$A$1:$D$50;column(A1);false);Sheet1!A1)
Read this as follows: Take the value of the first column in Sheet1 (old data). Look up in Sheet2 (updated rows). If present, output the value from the indicated column in Sheet2. On error, output the value for the current column of Sheet1.
Notes:
In my version of the formula, ";" is used as parameter separator instead of ",". That is because I am located in Europe and we use the "," as decimal separator. Change ";" back to "," if you live in a country where "." is the decimal separator.
A$1: means always take column 1 when copying the formula to a cell in a different column. $A$1 means: always take the exact cell A1, even when copying the formula to a different row or column.
After pasting the formula in A1, I extended the range to columns B, C, etc., until the full width of my table was reached. Because of the $-signs used, this gives the following formula's in cells B1, C1, etc.:
=IFERROR(VLOOKUP('Sheet1'!$A1;'Sheet2'!$A$1:$D$50;COLUMN(B1);FALSE);'Sheet1'!B1)
=IFERROR(VLOOKUP('Sheet1'!$A1;'Sheet2'!$A$1:$D$50;COLUMN(C1);FALSE);'Sheet1'!C1)
and so forth. Note that the lookup is still done in the first column. This is because VLOOKUP needs the lookup data to be sorted on the column where the lookup is done. The output column is however the column where the formula is pasted.
Next, select a rectangle in Sheet 3 starting at A1 and having the size of the data in Sheet1 (same number of rows and columns). Press Ctrl-D to copy the formulas of the first row to all selected cells.
Cells A2, A3, etc. will get these formulas:
=IFERROR(VLOOKUP('Sheet1'!$A2;'Sheet2'!$A$1:$D$50;COLUMN(A2);FALSE);'Sheet1'!A2)
=IFERROR(VLOOKUP('Sheet1'!$A3;'Sheet2'!$A$1:$D$50;COLUMN(A3);FALSE);'Sheet1'!A3)
Because of the use of $-signs, the lookup area is constant, but input data is used from the current row.

Related

Retrieve Cell Value in a separate column of Sheet 2 if Values from two columns in Sheet1 Match two columns in Sheet2

Intended behaviour
Where two values in the same row of two different columns MATCH two values in the same row of two different columns in another sheet, the data in the same row of the third column of the additional sheet is displayed in a third column of the original sheet.
For example...
Where Sheet1 A2 ("1") AND B2 ("A") MATCH Sheet2 A5 ("1) AND B5 ("A"), the value in Sheet2 D5 (1500%) should be displayed in C2 of Sheet1
I have read the below similar questions:
Match two columns in table to two columns in separate table and return value &
Match values in two columns and return value using vlookup from third column in Excel
and tried working them into my spreadsheet but the data I get back is either a "" (blank), "#VALUE" or "#NA"
The below formula seems to be the closest potential resolution but sadly it's spitting out blank from what seems to be an error 🤔
I have also tried the below formula with CSE (Ctrl +Shift + Enter) but nothing 😕
=IFERROR(INDEX(Sheet2!D2:D7, MATCH(Sheet1!A2:A7,Sheet2!A2:A7,0),MATCH(Sheet1!B2:B7,Sheet2!B2:B7,0)),)
Any assistance would be appreciated for this excel noob, thank you :)
You can try this in your Sheet1!C2:
=INDEX(Sheet2!$D$2:$D$7,MATCH(1,(Sheet2!$A$2:$A$7=Sheet1!A2)*(Sheet2!$B$2:$B$7=Sheet1!B2),0))

excel SUMIFS only on same date

I'm trying to create a formula in column K which sums all cells that apply , in column J, only when the following conditions are true:
dates are the same in column A
AND client name is the same in column B
For example, in cell K2, I want the sum of J2+J3+J4 because A2=A3=A4 and B2=B3=B4.
K5=J5 only, because there are no other dates with the same client name.
K6=J6+J7 because A6=A7 and B6=B7.
What kind of formula would I use for this? I can't figure out how to do it with a SUMIFS.
I would try using a pivot table with:
The names as row values
The dates as the column values
And funds received using SUM in the values column
Edit
Based on #pnuts comments here is how to get the values in column K. Put this in K2 and drag down.
=IF(OR(COUNTIFS($B$1:B3, B3) = 1, B3 = ""), SUMIFS($J$2:J2, $A$2:A2, A2, $B$2:B2, B2), "")
This formula will give blank values until the formula finds a new client on a new date. However, I still think using pivot table is a better solution.
However, I still find the pivot table
In cell K2 put following formula:
=IF(COUNTIFS($A$2:A2,A2,$B$2:B2,B2)=1,SUMIFS($J$2:$J$10,$A$2:$A$10,A2,$B$2:$B$10,B2),"")
Adjust row 10 value. It will be last row of your actual data.
Copy down as much you need.
EDIT
Uploaded file shows the cause behind formula not working correctly for you. It turned out to be whitespace characters in column B (names) data e.g.
Cell B3: "Moe John" has a trailing space.
Cell B10: Same case with "Doe Jane"
If you want to use above posted formula then all names shall be corrected. Or alternatively to deal with spaces you can adopt below approach.
=IF(COUNTIFS($A$2:A2,A2,$B$2:B2,"*"&TRIM(B2)&"*")=1,SUMIFS($J$2:$J$28,$A$2:$A$28,A2,$B$2:$B$28,B2),"")
Notice the change in COUNTIFS formula where B2 is now replaced with "*"&TRIM(B2)&"*".
Even such formula will take a beating if you have uneven whitespace characters in between your data. I'd suggest normalizing it as much as possible.

How to refer to multiple adjacent cells

I have a work sheet in which there are several cells with a specific entry - let's say "A". These are not all in the same rows/columns. After each cell is a date.
I need to count the number of cells containing "A" which also have a specific date in the cell immediately to its right. I've tried combinations of Countifs and Indirect, with no success. How can I achieve this?
This counts the number of times that there is A in column A and 1 in column B
=SUMPRODUCT(($A$1:$A$5="A")*($B$1:$B$5=1))
This outputs in cell D1
Not too difficult.
I have created a sample sheet with 8 rows and 5 columns of data.
See below, the formula in cell C12 counts the number of occurrences where the a cell with a date of October 31, 2017 is directly to the right of a cell that contains the text A.
If you want more info as to how this works, read on:
When searching for cells that contain A, you don't search in the last column of the data (in this case, column E) because it is impossible for a column to the right to have any date in it. This is why a portion of the formula says A1:D8="A" instead of A1:E8="A". This is the same reasoning why we start searching for a date in column B rather than column A in the formula.
You can achieve this with a helper row. Add additional row on top of your Worksheet. In cell "A1" enter formula below.
=COUNTIFS(A2:A2000,"A",B2:B2000,"YourDate")
Drag this formula to the rightmost of where you have data, then simply sum all values returned by formula.

Excel function that copies rows if they fall within the range of 2 dates

So at the top of my Excel sheet I have 2 cells, A2 and B2, where people can enter a starting and ending date.
On a seperate sheet I have an enormous list of starting and ending dates in columns A and B, and corresponding data for each of these 'events' in columns D through G. I need my function to copy all rows where the starting date falls between the two specified dates, and copy the data to the first sheet, in cells A4 - G4 through A100 - G100. (I just chose 100 as a large number, to make sure the area where the data gets placed is large enough)
I'm guessing this function I need includes the INDEX function, but I only know how to use it to look up one data cell at a time, not how to copy an entire range of cells.
Can anyone help?
No helper columns required.
Enter this formula into cell A4:
=IFERROR(INDEX(data!D$2:D$9999,SMALL(IF((data!$A$2:$A$9999>=$A$2)*(data!$A$2:$A$9999<=$B$2),ROW(data!$D$2:$D$9999),9E+99),ROW(1:1))-1),"")
This is an array formula and must be confirmed with Ctrl+Shift+Enter.
Now copy the formula to the range B4:D4.
Now copy the A4:D4 to the range A5:D100.
That's it.
Let's say Column C in the data sheet is blank, and free to add a formula.
Let's also assume that the data begins in row 2.
Then the following formula can be put in C2 & copied down:
=IF(AND(A2>=Sheet1!$A$2,B2<=Sheet1!$B$2),C1+1,C1)
Basically it is saying that if the beginning date of the current record is greater than or equal to the date the user is looking for, and the ending date is likewise within range, iterate the record, otherwise not.
At this point the user sheet can have a simple VlookUp as follows:
In D1: =VLOOKUP(ROW($A1),Sheet2!$C:$G,COLUMN(B$1),0)
Copy this across to G and down however many rows you like.

Convert Excel Columns into Rows

Please take a look at the attached snapshot.
How to convert the Original Table to the Required Table, in the easiest manner ?
Here, I have shared just a small sample, the real table is quite big having more then 100 rows / symbols and 100 columns / dates.
Therefor it is not possible to manually copy paste the data to change the table format.
The final output table will have just 3 columns "symbol, date and value" arranged according to the dates in ascending order.
Please suggest how to do this. Thanks
here it is.
Put Original table in one sheet, say Sheet1. Top left cell being A1 = Symbol
Go to another sheet, say Sheet2.
In cell A1 put: Symbol
In cell B1 put: Date
in cell C1 put: Value
Go to cell A2 and put this formula:
=INDIRECT("Sheet1!A" & 2+MOD(ROW()-2; X);TRUE)
Go to cell B2 and put this formula:
=INDIRECT("Sheet1!R1C" & 2+ROUNDDOWN((ROW()-2)/X;0);FALSE)
Go to cell C2 and put this formula:
=INDIRECT("Sheet1!R" &2+MOD(ROW()-2; X)&"C" & 2+ROUNDDOWN((ROW()-2)/X;0);FALSE)
In all formulas above, replace X with the number of Symbols you got. In your original table there are 4.
Now fill down as needed
Note: If functions don't work, use comma(,) instead of semicolon(;).

Resources