I cannot figure out how to use a variable range in SUMIFS. Hope someone can help.
This is the formula:
=SUMIFS($G$52:$G$122;$D$52:$D$122;$C11;$E$52:$E$122;$D11)
Or when using a table:
=SUMIFS(Details[Percentage];Details[Function];$C11;Details[Reason];$D11)
The sum range G52:G122 should be variable depending on numeric input.
Input 1 (January) is range J52:J122, input 2 (February) is range is K52:K122, input 3 (March) is range L52:L122, etc
Is this possible and if so, how?
I tried to use INDEX(), MATCH(), OFFSET() but just could not get it right.
Thank you.
The formula is in column Used and now refers to %(G) in the next table. It should refer to 1 of the columns January to December, dependig on numeric input (1 to 12).
You can use nested FILTER or INDEX function to pick column:
specify column by index:
=SUMIFS(INDEX($G$52:$R$122;0;<col_number>);$D$52:$D$122;$C11;$E$52:$E$122;$D11)
specify column by name:
=SUMIFS(FILTER($G$52:$R$122;$G$51:$R$51=<col_name>);$D$52:$D$122;$C11;$E$52:$E$122;$D11)
Related
I want to count the number of cells that meet two conditions:
sheet ABC's A2:A100 should be equal to the value of sheet XYC cell A8
the cell value in range D2:M100 = 1
Originally, I tried to use this formula:
=COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$D$2:$M$100,1)
But this gave me error #VALUE
I then decided to use the following formula to count each column separately and add them together.
=COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$D$2:$D$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$E$2:$E$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$F$2:$F$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$G$2:$G$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$H$2:$H$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$I$2:$I$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$J$2:$J$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$K$2:$K$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$L$2:$L$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$M$2:$M$100,1)
I am wondering if there are any other ways that allows me to shorten my formula?
Thank you.
You can use a boolean structure inside SUMPRODUCT() or just SUM() if your version of Excel supports dynamic arrays (ms365):
=SUMPRODUCT((ABC!A2:A100=XYC!A8)*(ABC!D2:M100=1))
I got an issue with Xlookup formula for the lookup array & return array. As the 1st one I need to manually select the range for lookup and return array, I try to use Xlookup with multiple criteria to match with the keyword instead of only matching one criteria. However, the result was appear to be different. Please help how to adjust the formula to remove the manual selecting range. Thank you.
G column is text
AE column is number
J column is text
Z column is number
W column is date
=XLOOKUP(AE3,工作表2!$Z$2:$Z$6,工作表2!$W$2:$W$6,,1)
=XLOOKUP($G3&$AE3,工作表2!$J:$J&工作表2!$Z:$Z,工作表2!$W:$W,,1)
Your sheet names showing in Chinese may be confusing some people.
I'm not aware of any syntax in Excel that allows you to concatenate columns as part of an array definition. It would be great if we could do this. The only way I know to do this is with another column and then use that for your array. You could add $J2&$Z2 to another column and then use that. If you added that to column H your xlookup() would be:
=xlookup($G3&$AE3, $H2:$H6, $W2:$W6,,1)
Here's how it looks. I showed the xlookup() functions in F9 and F10 (right aligned) and the results in G9 and G10.
I am looking to sum values in a row based on a horizontal month range and vertical name range.
Here is what I am trying to achieve:
**Name** 1 2 3 4 5
Michael $24,000 $36,000 $24,567 $45,000 $36,900
Jerry $27,000 $39,090 $55,567 $85,000 $39,900
Sandra $24,000 $36,000 $24,567 $45,000 $36,900
Michelle $24,000 $36,000 $24,567 $45,000 $36,900
I want to be able to sum based on the month range.
For example, If I want to know what the value is for Sandra in months 3-5 ($24,567 + $45,000 + $36,900)
So everytime I play around with the range it should give me the sum of those values.
I tried an index match match function but I could only do it for a specific month not a range.
This was the formula I used :
=INDEX(Quota!$A$3:$P$29,MATCH('Summary by Rep'!A7,Quota!$A$3:$A$29,0),MATCH('Summary by Rep'!B4,Quota!$A$3:$P$3,0))
Any help would be greatly appreciated!
Use this array formula:
=SUM(INDEX(B2:F5,MATCH(I4,A2:A5,0),N(IF({1},ROW(INDIRECT(I2&":"&I3))))))
confirm with Ctrl-Shift-Enter instead Enter when exiting edit mode:
Or this that can be entered normally:
=SUMPRODUCT(B2:F5*(A2:A5=I4)*(B1:F1>=I2)*(B1:F1<=I3))
Just building on Scott Craner's answers with another solution that does not involve array or array like formulas.
The INDEX function actually returns a cell address instead of a value. Therefore you can use index once to define your starting cell of the range to sum, and then again to define the end cell of the range.
=SUM(INDEX():INDEX())
So based on the above formula you just need to figure out how your are going determine the start cell and then repeat the process for your end cell. I did it with the MATCH function. and used the following formula:
=SUM(INDEX($B$2:$F$5,MATCH($H4,$A$2:$A$5,0),MATCH($I4,$B$1:$F$1,0)):INDEX($B$2:$F$5,MATCH($H4,$A$2:$A$5,0),MATCH($J4,$B$1:$F$1,0)))
One small caveat that I have not tested, is that your name list and month list will may need to be sorted in ascending order.
I have a excel formula as below,
COUNTIFS($A$8:$A$14,$A8,$B$8:$B$14,$B8)
Here I want the criteria range to be calculated with a simple logic.
Instead of $A$14 I want this value to be calculated A$8+4 i.e. $A$14
In other words, it should get the current row and add 4 to be the criteria range for COUNTIFS
How can this be done is excel within the COUNTIFS formula?
Cheers
You could use =OFFSET(Cell Reference, Rows, Columns) within your formula to achieve this, for example:
=COUNTIFS($A$8:OFFSET($A$8,6,0),$A8, etc...)
Lets assume that the size of your range to be returned is stored in the cell D1.
=COUNTIFS($A$8:INDEX(A:A,ROW($A$8)+D1),$A8,$B$8:INDEX(B:B,ROW($B$8)+D1),$B8)
If you want the range to be defined as a certain number of rows after the current row as stated in your question, then still assuming the number of rows to be added is in D1, you would use the following:
=COUNTIFS($A$8:INDEX(A:A,ROW()+D1),$A8,$B$8:INDEX(B:B,ROW()+D1),$B8)
Expanding on Oliver's answer. The full format of OFFSET allows you to specify a whole range, not just one cell. OFFSET(Reference, Row Offset, Col Offset, Height, Width) so you could do:
OFFSET(A8,0,0,4,1)
This specifies the range A8:A11. In the COUNTIF
=COUNTIF(OFFSET(A8,0,0,4,1),A8,...)
Locking cells with $ works the same way within OFFSET if needed.
Try this:
=COUNTIFS(INDIRECT("$A$8:$A$" & 8+6),$A8,INDIRECT("$B$8:$B$" & 8+6),$B8)
when using the sumif function how do you get the [sum_range] to only add the positive numbers?
so if the function is =sumif(A:H,C34,H:H) how do I only add the positive numbers in column H
In your posted formula =sumif(A:H,C34,H:H) because the test range is A:H , the range that is summed is actually H:O (the shape of A:H = 8 columns starting at top left cellof H:H) Not sure if this is what you intended. Given the overlap in the criterai and sum ranges I suspect not. BTW this means cell J34 will always be included in the sum
SUMIFS is only available in Exel 2007 and later and would work for =SUMIFS(H:H, A:A, C34, H:H, ">0")
Unlike the range and criteria arguments in the SUMIF function, in the SUMIFS function, each criteria_range argument must contain the same number of rows and columns as the sum_range argument.
If you are using Excel 2003 or earlier, or if the range behviour described above is required, you can use somthing like,
=SUM(H:H*(A:A=$C$34)*(H:H>0))
or
=SUM(H:O*(A:H=$C$34)*(H:O>0)) ' this one won't work as is, you will have to resolve the overlapping ranges
entered as an array formula (Ctrl-Shift-Enter)
You can use the SUMIFS function:
=SUMIFS(H:H, A:H, C34, H:H, ">0")
The sum_range is at the beginning in this case, instead of the end in this case