SUMIF function with criteria in another cell - excel

Say I have to sum up the cells in column B if their corresponding cells in column A <= the value in some specific cell in column C. Instead of SUMIF(A1:A10,"<=10",B1:B10), I tried SUMIF(A1:A10,"<=C1",B1:B10) and it didn't work.
How do you fix it so that the criteria of the SUMIF function involves the value in a specific cell? I'd like to set it this way because I have to apply the SUMIF function to the entire column. Ideally, the formulae in the cells of column D will be something similar to
=SUMIF(A1:A10,"<=C1",B1:B10)
=SUMIF(A1:A10,"<=C2",B1:B10)
etc.

Try this:
=SUMIF($A$1:$A$10,">="&C1,$B$1:$B$10)
Put it in D1 and fill down.

Related

Find the Last Cell Value of the 2nd Column Set for each 1st Column Cell in EXCEL

I have the following structured table in excel where 1000s of rows included.
I want to return the Last Cell Value of Column B for Each value in Column A.
For example:
For Cell A1 -> I want to return the Cell B5.
For Cell A6 -> I want to return the Cell B9.
I have tried with VLOOKUP, HLOOKUP, INDEX likewise so many formulas where I ended with more conflict situations. Can anyone please write down a Formula to give my requirement a life?
Array formula (Press Control + Shift + Enter while entering the formula) in cell C1 and copy it down.
=IF(A1="","",IFERROR(INDEX($A2:$B$20,MATCH(FALSE,ISBLANK($A2:$A$20),0)-1,2),LOOKUP(2,1/(B2:$B$20),B2:$B$20)))
if you don't mind using column C as a helper column you could use something like that:
If you won't use Array formula you can Use this solution:
like this image:
use column C as helper with this formula in first cell =OFFSET(A1;SUMPRODUCT(MAX(($A$1:$A1<>"")*(ROW($A$1:$A1))))-ROW(A1);0)
and use this formula in column D's first cell =IF(A1="";"";INDEX($B$1:$B$13;SUMPRODUCT(MAX((ROW($A$1:$A$13))*($C$1:$C$13=A1)))))
and copy fill-down to all cells.
Try this shorter, without helper column and non-array formula solution
In C1, formula copied down :
=IF(A1="","",INDEX(B1:B$9,MATCH(1,FREQUENCY(1,0+(A2:A$9<>"")),0)))

Return multiple values from a range

To return a value corresponding to another cell from a range if it matches with a cell, I found Chuff's solution helpful (in
Excel - match data from one range to another and get the value from the cell to the right of the matched data ):
=iferror(vlookup(b31,$f$3:$g$12,2,0),"")
However, if there are more than one cells within the column F which match with b1, the formula returns the value of only one cell from the column G.
Could it be modified so as to attract the value of more than one cell?
Thank you!
To return multiple corresponding Vlookup values you should use this formula: =IFERROR(INDEX($B$2:$B$9,SMALL(IF($E1=$A$2:$A$9,ROW($A$2:$A$9)-ROW($A$2)+1),COLUMN(A1))),"")
Because it it an array formula, please enter it using combination of CTRL+SHIFT+ENTER . For example, if you have you lookup range in A:B column, and lookup values in D column, then please enter formula above to F1 cell, then drag it to the right and to the bottom. You should now see all instances of Vlookup next to the lookup value in D column.
If you have only values which you want to sum in case they correspond to your value in cell B31, then simply use SUMIF formula like this =SUMIF($F$3:$F$10,$B31,$G$3:$G$10) entered in cell C31.

dynamically change column in excel sumifs

I have created a dynamic table in excel through a SUMIFS formula:
=SUMIFS(data!$D:$D,data!$B:$B,Sheet2!B$3,data!$C:$C,Sheet2!B$2,data!$A:$A,Sheet2!$A4)
this is what the table looks like:
while the data looks like:
Now I am picking values from the column Order Total. What I would like to do is to insert a dropdown list on cell B1 to dynamically select from what column I want to get the data.
Is there a way to add this in my formula?
Ok, since order total is in column D, I'll replace the first piece of the sumifs with the indirect, and I'm assuming the data is on the data worksheet, as well as cell B1 which you want the dropdown: =SUMIFS(indirect("data!$"&data!B1&":$"&data!B1),data!$B:$B,Sheet2!B$3,data!$C:$C,Sheet2!B$2,data!$A:$A,Sheet2!$A4)
What the indirect does is concatenate (using the '&' symbol) the string information with the cell information, then change it to a cell reference. If you copy everything within the indirect into another cell (preceded by "="), it would return your original data!$D:$D, if you put "D" in cell B1. This then becomes the cell references for the sumifs formula when using the indirect formula. If you change cell B1 on the Data worksheet to "E", the formula would evaluate to data!$E:$E within the indirect, which would then mean the sumifs formula references column E.

Count Cell if value in Column A is 1

I'm looking to get my formula to work. I want it to count how many cells in column G contain 6/7/8, but only if the cell in Column A contains a 1.
That is what I currently have.
{=SUM(IF(A4:A72=1,1,0) AND IF(G4:G72="6/7/8",1,0))}
If you're just looking for a count, using Countifs will be helpful. Since it's a simple comparison on cell A1, I'd put it in an If statement like so:
=IF(A1=1,COUNTIFS(G:G,"6/7/8"),FALSE)

Excel string to criteria

I have an Excel formula like this:
=SUM(SUMIF(A2:A11;{"1010";"1020"};B2:B11))
Now I need to make the formula more dynamic. Instead of changing the formula itself, I should be able to change some cell (linked in the formula). This change will be reflected in the formula.
Ex:
=SUM(SUMIF(A2:A11;D2;B2:B11))
Cell D2 should return something similar to {"1010";"1020"} in the first formula.
I tried this and it works only if in the column D I have one value (ex: 1020), but if there are two values (ex: 1010;1020) it returns 0.
This is how my table looks like:
As you can see, it shows 0 for the cell where D2 has two values; but it works when there is only one value. All the rows in column D will be like cell D2, with 2 or more values, this is why it has to be dynamic using a list in the formula.
How can this be achieved in Excel? How can I make a list from the cell?
Using multiple cells would be easier! If the formula cell is one to the right of the criteria cell, you can define a named formula (Using Name Manager) called, say, GetList, which refers to this formula:
=EVALUATE("{"&INDIRECT("RC[-1]";0)&"}")
Then your formula becomes:
=SUMPRODUCT(SUMIF(A2:A11;GetList;B2:B11))

Resources