I would like to calculate the sum of a column total in a table, base on the name of the column header.
For example, below is a table of monthly sales by each person (from cell A4 to M7).
I would like to calculate the total monthly sales in Cell D13 with the month as an input variable (as in Cell B13).
My thought is =SUM(INDEX(B5:M7,MATCH(B13,B4:M4,0))) where I tried to use index and match function to find the range, then use sum function. It returns with an error and I am currently stuck here.
Your help is appreciated.
Using SUMPRODUCT function
In D13 enter formula :
=SUMPRODUCT((B4:M4=B13)*B5:M7)
Related
I am absolutly not into Excel. I have a cell containing this formula:
=SUM(D2:D33)/SUM(F2:F33)
I want to adapt this formula in the following way: it has to skip a row (do not take into consideration in the previous formula. so the D cell value is not summed and the F value is not summed) if the B cell value has "SELL" as value.
it represents something like this related to a cryptocurrency calculator:
The I2 cell contains the previous formula that calculate the average buying price. I want to exclude from this calculation the row representing a sell operation.
What can I do?
EDIT-1: tried with this formula but I am obtaining this error message:
=SUM(FILTER(D2:D6,B2:B6="BUY"))/SUM(FILTER(F2:F6,B2:B6="BUY"))
You can use SUMIF(). Try-
=SUMIF(B2:B6,"BUY",D2:D6)/SUMIF(B2:B6,"BUY",F2:F6)
Or SUMPRODUCT()
=SUMPRODUCT((D2:D6)*(B2:B6="BUY"))/SUMPRODUCT((F2:F6)*(B2:B6="BUY"))
Or FILTER() formula with Excel-365.
=SUM(FILTER(D2:D6,B2:B6="BUY"))/SUM(FILTER(F2:F6,B2:B6="BUY"))
I am trying to query a list of sales stored in Excel using a dynamic array formula referencing a spill range and this does not work.
Here is the context:
I have a table tabSales containing the sales, with the following data : date, customer, amount, year (calculated using =YEAR([Date])
I want to display on another sheet the amount sold year by year for a given customer to be selected by the user in cell B1 (named SelCust)
Here is what I have tried on the report sheet:
I have used the UNIQUE and FILTER functions to make the report display on column D the years where the selected customer has actually bought something : =UNIQUE(FILTER(tabSales[Year],tabSales[Customer]=SelCust)) (formula input in cell D2)
I have then tried to use the SUM and FILTER functions and Excel's spill range feature to calculate for each year the total amount sold to the selected customer : =SUM(FILTER(tabSales[Amount],(tabSales[Year]=D2#)*(tabSales[Customer]=SelCust))) (formula input in E2)
Unfortunately, this last formula unfortunately does not work:
Excel returns #N/A in E2
Cell E2 does not spill over E3, E4, ...
The lack of spilling makes me wonder whether the spill range reference within the FILTER function is recognized...
How could I get this formula to work ?
Sales table
Non-working formula
Use SUMIFS():
=SUMIFS(tabSales[Amount],tabSales[Year],D2#,tabSales[Customer],SelCust)
This should return an array properly.
If one wants to do both columns in one dynamic formula we can use LET and CHOOSE:
=let(
slcust,tabSales[Customer],
amt,tabSales[Amount],
yr,tabSales[Year],
unYr,UNIQUE(FILTER(yr,slcust=SelCust)),
sm,SUMIFS(amt,yr,unyr,slcust,SelCust),
Choose({1,2},unyr,sm))
I am trying to create a formula that will compare the value in one column and give the lowest value in another column.
For example if column A has a product code and column B has a price, how can I get column C to compare the values in column A to give the lowest stock price for each product code?
There's no MINIF (that's min if, not mini f) function (yet?), so back to the old days when one had to use array formulas before COUNTIF and SUMIF came about:
=MIN(IF($A$2:$A$8=A2,$B$2:$B$8)) in C2 and drag down. Be sure to enter as an array formula using Ctrl+Shift+Enter instead of just Enter
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"
I am using following formula to calculate sum based on multiple sheets, here is the scenario
Total 2 sheets, Data and Translation,
In Data sheet i have employee name in C Column, Hours in J column,
In Translation sheet i have Department in A Column, Employee name in C column, and Rate in E column, so i have Department name, from that name i need to calculate total $ spent,
I have following formula, that will capture total rate (COUNTIF(H7,Translation!$A$2:$A$27)*Translation!$E$2:$E$27)
but its not calculating total hours (LOOKUP(IF(H7=Translation!$A$2:$A$27,Translation!$C$2:$C$27),'Data '!$C$2:$C$410,'Data '!$J$2:$J$410)
Please let me know
=SUMPRODUCT(IFERROR(LOOKUP(IF(H7=Translation!$A$2:$A$27,Translation!$C$2:$C$27),'Data '!$C$2:$C$410,'Data '!$J$2:$J$410),0)*COUNTIF(H7,Translation!$A$2:$A$27)*Translation!$E$2:$E$27)
You can't use LOOKUP here because the lookup range isn't sorted ascending - you can use SUMIF in place of LOOKUP, try this "array formula"
=SUM(SUMIF(Data!C2:C500,IF(B2=Translation!A2:A500,Translation!C2:C500),Data!J2:J500)*COUNTIF(B2,Translation!A2:A500)*Translation!E2:E500)
confirmed with CTRL+SHIFT+ENTER