Sum only matched values from two columns - excel

Hello Everyone,
Does anyone know how to sum the Hours from column B (Hours) if column A numbers matched with column E and sum by months.
Example, take February data as an example, since only 3000 & 4000 existed in both column A & column E, that's why I need to sum the hours (20+10=30) from column B by it's month below.
I also attached the example excel sheet below.
https://www.dropbox.com/s/0s51g1i8g6s6e2d/Test.xls?m
Thanks in advance. :-)

You could get complicated with customer functions but if having an extra column (potentially hidden) doesn't matter then this would work:
In cell D2 enter:
=iferror(vlookup($A2,$E$2:$E$20,1,FALSE),"x")
Drag the formula down.
Under each month you can then put:
=sumifs($B$2:$B$16,$C$2:$C$16,B$22,$D$2:$D$16,"<>x")
Drag the formula across
This assumes you can change the month format in either column C or row 22 to be the same, ie. Jan, Feb, Mar or January, February, March etc.
Written on the fly and not tested so excuse any minor errors...

Both answers posted thus far are just fine, but just as an alternative, here's what I would do. Put this formula in cell D2 and drag it down:
=IF(NOT(ISNA(VLOOKUP(A2, $E$2:$E$20, 1, FALSE))), B2, "")
Then if you make a column containing the names of the months, say from G2 to G7 you have February, March, ..., July, you can put this formula into H2 and drag it down:
=SUMIFS($D$2:$D$16, $C$2:$C$16, G2)
That should get what you want.

Put this formula in Cell D2 and drag down:
=IF(NOT(ISERROR(MATCH(A2,$E$2:$E$20,FALSE))),B2,"")
In row 22, change the month names to be the full name, OR in column C, change the month names to abbreviated 3-letter names, this is so we can make use of the SumIf function.
Then, in Cell B23, put this formula and drag it across:
=SUMIF($C$2:$C$16,B22,$D$2:$D$16)
(I put the formula in row 24 to check against the data you already had in Row 23)

Shouldn't be much harder without a helper column. Just make sure you have full month name in row 22 to match column C data then use this formula in B23 copied across
=SUMPRODUCT(SUMIFS($B2:$B16,$C2:$C16,B22,$A2:$A16,$E2:$E20))

Related

How to fix search to header cell?

I have a table like this:
Name
Response
Thursday
A
Monday, Thursday
Yes
B
Tuesday
No
C
Wednesday
No
This is an output of a Google Form response that I use to collect data, In Column C, every cell contains this formula:
=IF(ISNUMBER(SEARCH("Thursday",B2)),"Yes","")
To populate the "Yes". However, its quite cumbersome to replicate this if I want change "Thursday" to something else. When I try to insert it as C1, as I populate down the cells, it auto increment to C1,C2,C3 etc.
Is there a way to fix the formulate to
=IF(ISNUMBER(SEARCH(C1,B2)),"Yes","")
Across all cells and just have B2 increment?
Thanks!
The cell reference that you are using, such as C1, is relative to the formula position. So when you copy the formula one row down, C1 becomes C2 and so on.
To prevent this you need to make the row and or column address absolute so that C1 remains C1 when the formula is copied somewhere else. To make a row or column absolute, precede the row and or column by the character $. To keep the row absolute, you would use C$1 instead of C1. The key F4 will help cycle through the option when the cell address is selected in the formula.

Sum based on dates on multiple column in Excel

1 st column date and 2nd column amount 3rd column date and 4th column amount .. is going on.
I want to sum based on date, If date between 2019 to 2020, i need sum the amount.
I was able to get the function SUMPRODUCT to work, assuming I understand what you want to do. (I think you want a billings total for each year, is that right?)
See this ExcelJet article on SUMPRODUCT.
There's probably a way to make this even shorter, but here's one solution:
See screen clip (I'm not allowed to post images yet.)
Formula for cell C6: =SUMPRODUCT(--(YEAR(B$3:B$4)=2019),C$3:C$4)
Copy that into cells E6, G6, I6, K6, and M6. The column references will adjust.
This will give you the 2019 totals for each of the 6 periods in row 6.
Formula for cell C7: =SUMPRODUCT(--(YEAR(B$3:B$4)=2020),C$3:C$4)
Copy that into cells E7, G7, I7, K7, and M7. The column references will adjust.
This will give you the 2020 totals for each of the 6 periods in row 7.
Formula for cell N6: =SUM(B6:M6). This is the 2019 total (the sum of row 6).
Formula for cell N7: =SUM(B7:M7). This is the 2020 total (the sum of row 7).

List adjacent cell values if date belongs to month 1, 2, 3 (jan, feb, mar...) etc

I have a list of dates in column B and a list of working hours in column C. I would like to get all the values (hours) listed in column D from column C if adjacent cell value in column B belongs to Month 1 (January).
Then I would like to drag the formula downwards and to the right so that column E = February, columnF = March etc.
The answer to column D should be a list with all the hours from column C that are in January in columnB and by dragging the formula down and to the right to get the formula working for all the other Months as well.
Note that the dates might be in disorder!
I've tried with INDEX MATCH but I can't get my different formulas to work with the MONTH() function. I've tried to find an answer to the problem for many hours now without success. All help appreciated.
Double check that your dates are being read correctly by first putting =MONTH(A2) and ensuring the appropriate value (1 - 12) comes out. Once you have verified that the following should do what you want.
In column D: =IF(MONTH($C2)=1,$B2,"") This formula can be dragged to the right first and replace 1 with 2 - 12 as appropriate for the month. Then copy them down.

Finding the right vlookup/index formula in excel to match weeks and dates

I have two sheets on excel. Sheet1 consists of data from other sheets so Sheet1 is the main Sheet to look at. I am having trouble finding a vlookup formula that can get the accurate information from Sheet2. On Sheet1, in column A I have item numbers and in row 1 I have dates that alternate weekly (16-Jul, 23-Jul, 30-Jul, 6-Aug, etc.). On Sheet1, for each weekly date and item number I get a numerical amount from Sheet2. Sheet2 has the same exact layout except instead of dates in row 1, there are week numbers ([starting from the example dates above] 29, 30, 31, 32, etc.). The week numbers change daily on Sheet2 so for example today it can be 29,34,45,46,51. Right now I have a large range to account for multiple possible future item numbers and weekly numbers andthe best I have is:
=IF(ISNA(VLOOKUP(LEFT($A2,LEN($A2)),'Sheet2'!$A$2:$AZ$8000,COLUMN()-4,0)),"",VLOOKUP(LEFT(Summary!$A2,LEN(Summary!$A2)),'Sheet2'!$A$2:$AZ$8000,COLUMN()-4,0))
but the problem lies with the "COLUMN()-4" as I do not know what this does nor does it capture the correct date because it gets the amount but it assumes that all possible dates on Sheet1 (16-Jul, 23-Jul, 30-Jul, 6-Aug, etc.) have no gaps when on Sheet2 there are because not all week numbers are listed. I cannot list them all on Sheet2, only whatever week number and item number is updated and appears, so there are gaps (whereas Sheet1 has every date and whatever does not appear is just left as a blank cell since it is not relevant). Finding a way to change the formula to match the week number with the date might be a possible solution? Hope this makes sense! The workbook is saved daily with a new date.
google sheet link
Sheet1
Sheet2
Try this in Summary!B2 then fill both right and down.
'excel formula
=iferror(hlookup(weeknum(B$1, 2), Sheet2!$B$1:$AZ999, match($A2, Sheet1!$A:$A, 0), false), "")
'google-sheets formula
=iferror(hlookup(weeknum(B$1, 2), Sheet2!$B$1:$AZ, match($A2, Sheet1!$A:$A, 0), false), "")
The accuracy of the HLOOKUP will depend on whether your WEEKNUM's match the Excel default for WEEKNUM. I noticed your dates are the Monday starting the week so I've use WEEKNUM(<date>, 2). If your weeknum's are offset from excel defaults (implied by the COLUMN()-4 parameter) then this will have to be adjusted.
Shared worksheet
Why don't try to use :
Use weeknum() for week number of the year. instead of manually setting it. eg Let A1 = the date, =WEEKNUM(A1)
For checking of empty cell , use iferror() or if() to check/zero-fill to check for blank cell. eg. =IF(A1="",WEEKNUM(A1),"")
Use index-match instead of vlookup. It may be used to look for match both vertically and horizontally.. ref -> http://www.mbaexcel.com/excel/how-to-use-index-match-match/
eg > Let A2 = a, B2 = b, C2 = c, A3 = 30, B3 = 40, C3 = 50 . using A5 as text(a/b/c) input, =INDEX(A3:C3,1,MATCH(A5,A2:C2,0))
eg2 > Let A10 = a, A11 = b, A12 = c, B10 = 30, B11 = 40, B12 = 50 , =INDEX(B10:B12,MATCH(A5,A10:A12,0))
Hope that helps. (:
+-------[ Edit ]---------+
Thanks for the shared files & screenshoot. Congratulations on finding the solution =IFERROR(INDEX(Sheet2!$B$2:$AZ$8000,MATCH($A3,Sheet2!$A$2:$A$8000,0),MATCH(WEEKNUM(B$1),Sheet2!$B$1:$AZ$1,0)),"") on your own. It is indeed a very good solution. Keep it up. (:

Insert rows into excel range via formulae

I have the following range in column A :
01-Mar-12
01-Apr-12
01-May-12
01-Jun-12
01-Jul-12
01-Aug-12
01-Sep-12
01-Oct-12
01-Nov-12
01-Dec-12
01-Jan-13
01-Feb-13
01-Mar-13
01-Apr-13
01-May-13
01-Jun-13
01-Jul-13
01-Aug-13
01-Sep-13
In column B, I would like the same list of dates ( i.e. March 12 -> Sep 13), but I would like every August to be duplicated:
01-Mar-12
01-Apr-12
01-May-12
01-Jun-12
01-Jul-12
01-Aug-12
01-Aug-12
01-Sep-12
01-Oct-12
01-Nov-12
01-Dec-12
01-Jan-13
01-Feb-13
01-Mar-13
01-Apr-13
01-May-13
01-Jun-13
01-Jul-13
01-Aug-13
01-Aug-13
01-Sep-13
I can add as many columns in between as I like, but it must be done with formulae.
I'm having a little trouble figuring this out - any help would be much appreciated.
A formula is not capable of inserting rows.
Copy ColumnA to ColumnB, insert a cell and shift down immediately under each Aug and in the blanks created enter:
=R[-1]C
This formula works, assuming the values in column A are unique. Paste the formula into cell B3.
=IF(AND(MONTH(B2)=8,MONTH(B1)<>8),B2,INDEX(A:A,MATCH(B2,A:A,0)+1))
The current formula assumes that B1 and B2 are part of the list in column B. You'll have to manually fill in the values for B1 and B2 unless you change the formula a little.
What the formula does:
If B2 is August and B1 is not, then B3 copies the value of B2.
Otherwise B3 is the date in Column A found under the date B2.
You can then copy the formula into the remaining cells below B3.

Resources