perform function on criteria in SUMIF function - excel

I am writing a SUMIF function on a range with a format such as:
A B
1 1.1 5
2 1.2 5
3 1.3 5
4 2.1 5
5 2.2 5
I want the SUMIF to group values together by their integer, i.e.:
A B
1 1 15
2 2 10
I can do this by creating a third column C and applying INT(A) so that:
A B C
1 1.1 5 1
2 1.2 5 1
3 1.3 5 1
4 2.1 5 2
5 2.2 5 2
and (for 1)
=SUMIF(C:C, 1, B:B)
Is there a way to do this in one cell? i.e.
=SUMIF(A1:A5, "int(range) = 1", B1:B5)
I have also tried:
=SUMIF(A1:A5, "1*", B1:B5)
and
=SUMIF(A1:A5, 1&"*", B1:B5)
But these also do not work

You can use SUMPRODUCT e.g.
=SUMPRODUCT(--(INT($A$1:$A$5)=C1),$B$1:$B$5)
INT($A$1:$A$5)=C1 produces an array of TRUEs and FALSEs. The -- operator converts that to an array of 0s and 1s. Then you multiply by the values in B.

Formula in cell F12 is:
=SUMIFS($B$1:$B$5;$A$1:$A$5;">="&E12;$A$1:$A$5;"<"&E12+1)
Drag down

With Excel 365 you can do it like-
=LET(x,UNIQUE(INT(A1:A5)),y,SUMIFS(B1:B5,A1:A5,">="&x,A1:A5,"<"&x+1),CHOOSE({1,2},x,y))

Related

Feeding Multiple Distant Cells as One Array in Excel?

I have the following table in Excel.
A B C D E
1 i x y mu sigma
2 0 1 2 =average(b$1:b1,b3:b$12) =stdev.s(b$1:b1,b3:b$12)
3 1 3 4 =average(b$1:b2,b4:b$12) =stdev.s(b$1:b2,b4:b$12)
4 2 2 1 =average(b$1:b3,b5:b$12) =stdev.s(b$1:b3,b5:b$12)
5 3 1 2 ... ...
6 4 2 5
7 5 4 7
8 6 8 1
9 7 2 3
10 8 5 9
11 9 1 3
The ith mu calculates the average without the ith observation—the leave-one-out average. I can also calculate the leave-one-out standard deviations, but how can I do this for the leave-one-out correlations then? correl requires two arrays and I cannot feed two or more distant cells as one array using commas. Can I input non-consecutive cells as one array? For example, I tried =correl((b$1:b1,b3:b$12),(c$1:c1,c3:c$12)), but failed. Thanks for your reading.
Because CORREL takes arrays we can use an array formula:
=CORREL(INDEX(B:B,N(IF({1},MODE.MULT(IF(ROW($B$2:$B$11)<>ROW(),ROW($B$2:$B$11)*{1,1}))))),INDEX(C:C,N(IF({1},MODE.MULT(IF(ROW($C$2:$C$11)<>ROW(),ROW($C$2:$C$11)*{1,1}))))))
Use this easier array formula as per the OP(I overthought this):
=CORREL(IF(ROW($B$2:$B$11)=ROW(),"",$B$2:$B$11),IF(ROW($C$2:$C$11)=ROW(),"",$C$2:$C$11))
Being an array formula one needs to use Ctrl-shift-Enter instead of Enter when exiting edit mode.
This will pass two arrays of only the numbers not on the row where the formula is placed.
Now, eventually when microsoft releases the dynamic array formula into Office 365 this can be simplified using FILTER()
=CORREL(FILTER($B$2:$B$11,ROW($B$2:$B$11)<>ROW()),FILTER($C$2:$C$11,ROW($C$2:$C$11)<>ROW()))

Excel using SUMIF to calculate totals of multiple columns

I'm trying to use Excle's SUMIF to calculate totals of Col1 to Col5 for dates that are similar.
My formula is as follows =SUMIF($A2:$A7,A10,$B2:$F7), but this only gives me the total of a single column.
How can I get the Totals of all the columns based on the date like I've shown in my results.
Date Col 1 Col 2 Col 3 Col 4 Col 5
1/5/2017 1 2 2
1/5/2017 5 3 1
1/5/2017 9 5 5
2/5/2017 10 5 3
2/5/2017 20 10 3
2/5/2017 6 8 1 5
Desired Results
1/5/2017 15 7 7 3 1
2/5/2017 30 11 11 11 8
use below formula in cell B11
=SUMIF($A$2:$A$7,$A11,B$2:B$7)
Per the example you provided, One solution is to use SUMPRODUCT
Multiplies corresponding components in the given arrays, and returns the sum of those products
Microsoft Docs give a thorough example, but per SO etiquette, here is an example in case of link-rot: [FYI, I used absolute reference for easier filling across, arbitrary how you get it done though]
Forumlas shown:
Formula is kind of hard to see without clicking on image:
=SUMPRODUCT(($B$3:$B$8=$B$11)*C3:C8)
This basically breaks down like this, it searches the B:B column for a match, and it will naturally return a true or false for the match, or 0/1 counterparts, and multiplys that by the number found in the column to the right (C3:C8), so it will either be 1 * # = # or 0 * # = 0

assign cell to 4 categories based on 4 equal part of a max value

How do i assign a cell value to 1 of 4 catergories (1-4) based on a max value divided into 4 euqal parts.
e.g. max value is 4, then category 1 should be calculated like 1/4, category 2 like 2*(1/4) an so forth...
category 1 is the range 0 to <1
category 2 is the range 1 to <2
category 3 is the range 2 to <3
category 4 is the range 3 to 4
How is that possible?
Example data
a1 category
1.1 2
2.0 3
3.1 4
4.0 4
2.2 2
You can use the lookup function to do what you want. Something like this seems to work:
=LOOKUP(A1,{0,1,2,3},{1,2,3,4})
There is either a typo or a contradiction in your source data. Is a 3.1 a category 4 (as your rules state) or a 3 (as your example shows). In my formula, anything between 3 and 4 fall in to a category 4.
Anything greater than a value of 3 gets a category of 4. The formula is pretty straight forward (if a value is greater than or equal to 0 and less than 1, it returns 1. If the value is greater than or equal 1 and less than 2, it returns 2, etc).

how can we search a number from multiple rows/columns in excel

I have 3 columns. 3rd column is in sorted way which is numbers from 1 to 7.
2nd and 3rd column ares number between 0 to 9.
I want to search numbers in 3rd column between A1 to B7.
i have used the below formula to calculate the same and i am getting correct.
=IF(ISERROR(VLOOKUP(C1,A:A,1,FALSE)),IF(ISERROR(VLOOKUP(C1,B:B,1,FALSE)),"Not found","Found"),"Found")
However when am using full block(A1:B7) it is not working.
=IF(ISERROR(VLOOKUP(C2,$A$1:$B$7,1,FALSE)),"Not found","Found")
Considering N number of columns, how can we achieve the same.
2 7 1 Found
4 5 2 Found
6 4 3 Found
7 2 4 Found
2 1 5 Not found
3 9 6 Found
1 2 7 Found

"The formula refers to a range" error in Excel

Am new to Excel, please help me with this:
A B
2 9 =IF(A2:A6>=7,"1","0")
3 4
4 7
5 4
6 5
For B2 the formula works perfectly fine but in B3 it selects from A3:A6.
I know the concept of Absolute referencing. But here in this example it should basically work without any errors, right?
A B c
2 9 1 =Sum(A2:B2)
3 4 2
4 7 33
5 4 3
6 5 22
The above example works fine. What is the difference between two?
If you want the A2:A6 range to float down as you copy the formula to other rows, use:
=IF(MAX(A2:A6)>=7, 1, 0)
However, if you want row 6 locked as the finite terminator of the range then lock it as absolute with a $ like this,
=IF(MAX(A2:A$6)>=7, 1, 0)
        

Resources