SUBTOTAL formula? - excel

I need a formula that uses the SUBTOTAL formula in a FILTERED table (Range A2:B50).
Column A contains Name and column B the amount in sheet1.
A1 contains the criteria name and in B1, I am looking for a formula that sums the amounts if it finds the criteria name (table Range A2:B50)
Does anyone know how I can solve this with a formula?

Using the answer given in this link:
https://superuser.com/questions/709709/combining-sumif-and-subtotal-for-dynamic-subtotal
This formula should work:
=SUMPRODUCT(SUBTOTAL(109,OFFSET($B$2,ROW($B$2:$B$50)-ROW($B$2),,1)),--($A$2:$A$50=$A$1))

Related

How to sum with index match formula in MS excel

I would like to sum the data in column F (Sheet1) and show the result in column B (Sheet1)(From B4 to B9).
But the sum range should be created using vlookup or index/match.
The column E in sheet1 matched with Column B in sheet2 and take the column A values in sheet2.
Then sum the data in column F (Sheet1)
=SUMIF(E4:E13;VLOOKUP(A4;Sheet2!A17:B30;2;FALSE);F4:F13)
=SUMIF(E4:E13;INDEX(A17:A30;MATCH(A4;Sheet2!B17:B30;0);1);F4:F13)
I used the formula above but its not working.
Vlookup takes only first value And index macth showing wrong number.
Can anyone help me? Thanks
Plz try this starting in B4:
=SUMPRODUCT(F$4:F$13*COUNTIFS(A$17:A$30;A4;B$17:B$30;E$4:E$13))
(I am testing this in Excel 365 - it may need array entering in Excel 2010).
Assumes there are no duplicates in the Sheet2 data - if there were, you would need:
=SUMPRODUCT(F$4:F$13*(COUNTIFS(A$17:A$30;A4;B$17:B$30;E$4:E$13)>0))
In case a 2 steps solution may work for you, you can do:
Formula in cell C17 is =IFERROR(VLOOKUP(B17;$E$4:$F$13;2;FALSE);0)
Formula in cell B4 is =SUMIF($C$17:$C$30;$A$17:$A$30;A4)
Drag down both formulas

SUM with INDEX and MATCH

I have 2 worksheets that are connected through a unique ID column shared by the two sheets. I made the two below spreadsheets to test the formula as my actual data is quite long.
I am using the INDEX and MATCH formulas to pull a value from Sheet2 to populate a cell in Sheet1 if the ID value found in the row of Sheet1 matches an ID value found in Sheet2. I can accomplish this with the following formula
=INDEX(Sheet2!B:B,MATCH(Sheet1!A:A,Sheet2!A:A,0))
However, what I am actually after is for the INDEX to SUM of all values in the WGT column on Sheet2 on Sheet1 when there is a MATCH between the two ID columns (I know with this test data there are two instances of every ID on Sheet2). The above formula only INDEXes the first WGT value when a MATCH is found between the ID columns.
I am pretty sure I am supposed to use some variation of the SUMIF formula but I can't seem to get one that works at all. Thanks for any help!
The syntax for Sumif is Sumif(criteria range, criterion, [sum range]). So, you would need in Sheet2, cell B2
=sumif(Sheet1!A:A,Sheet2!A2,Sheet1!B:B)
In words: generate a sum or all numbers in column B of Sheet1, where column A of Sheet1 equals the value of cell A2 on Sheet2.
Copy that down.
Alternatively, you could click in the data of Sheet1 and insert a pivot table. Drag the ID field into the Rows area and the WGT field into the Values. Just a few clicks, no formula.
Another option to use Sum + Index function
In sheet1, B2 array formula copied down :
=SUM(INDEX(Sheet2!B:B,N(IF(1,(Sheet2!A:A=A2)*ROW(Sheet2!A:A)))))
This is an array formula and needs to be confirmed by pressing with Ctl + Shift + Enter.

Range row number reference from another cell in Excel

Edited: So I made the question more complicated. If I would like to do a 'what if ' analysis which requires to be able to refer the last row to sum from another cell to the sumif formula. How can I do that?
Just drop the row numbers from your formula and use the entire columns:
=SUMIF(A:A,">4",B:B)
The beauty is that SUMIF will disregard non-nmeric rows anyway.
To sum up and stop at a certiain row, you can use SUMIFS with ROW:
=SUMIFS(B:B,A:A,">4",C:C,"<" & D2)
Where D2 holds the row number using the formula =ROW(<CELL>), i.e: =ROW(A2) in cell C2:

updating a worksheet with another sheets values

This might be easy for you but i need to use one vlookup formula since i am dealing with many numbers in two Columns.
I have two sheets one of them is Sheet1 other one is Sheet2
Both of them have two columns. Columns A contains "Materialnumber" and Column B contains "Status". Sheet1 has more "Materialnumbers" inside then Sheet2
but Sheet2 includes correct "Status", so thatswhy if "Materialnumbers" are matching i would like to have the "Status" value of Sheet2 in Sheet1's Column C.
I know i should write the vlookup code in Sheet1's Column C. But what is the right formula for this?
Thanks in advance.
You're right - just a VLOOKUP needed in column C.
In C2 put this formula:
=VLOOKUP($A2,Sheet2!$A$1:$B$12,2,FALSE)
It looks at the value in Sheet1 A2.
Compares that value against the first column in the range $A$1:$B$12 (update the range as required).
Returns the value from the second column (B).
Only returns on an exact match (FALSE).
Try this in cell C2 on Sheet1:
=VLOOKUP($A2,Sheet2!A:B,2,0)

google spreadsheet lookup query for whole sheet

this is my spreadsheet, i want to create a new sheet with the following aggregation: I have a table with date column and sum column. in the sum column I want to sum the quantity of each row the date appears. For example, for 7/5/2015 it will sum B4, B5, B10, B11, B15, B17, B22, B25, B29.
EDIT: My range should contain the whole sheet, from d to infinity and from 2 to infinity and I'm using google spreadsheet
I tried this formula, but it returns error:
=LOOKUP(A2,Sheet1,sum(!b))
please try the following:
=SUMIFS(B:B;F:F;"<>")
i hope this helps,
best - AB
Or you could try my favourite function, SUMPRODUCT :
=SUMPRODUCT(SIGN((F:F=$A$1)+(E:E=$A$1)+(D:D=$A$1))*B:B)
where $A$1 holds your lookup value, i.e. 7/5/2015
Should work for both googlesheets and excel.
Didn't try hard, but maybe this works too (adapt "AA" to your last column):
=SUMPRODUCT(D:AA=$A$1))*B:B)
You could even try to automatize the "AA" part with a =MAX(1:1) (what is the number of the last column in row 1?) coupled with the OFFSET function.
Explanations here:
Sumproduct - Multiple criteria with "or"

Resources