Excel formula to add values based on certain criteria - excel-formula

Can you please help me out in obtaining this Excel formula, had tried but unable to get the expected.
If the range of A1 to A6 has starting char with S, then the corresponding B values should be added and the result should be shown in a cell.
I tried below formula, but not getting as expected:
=VLOOKUP("S*",A1:A10,2,FALSE)

VLOOKUP will only return the first item. If you want to find the Sum of cells that match a criteria, use SUMIF or SUMIFS:
=SUMIF(A4:A9,"SR*",B4:B9)
'Find the sum of Column B where Column A starts with "SR"'

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

How to do a sumif formula based on criteria in a column

I am trying to do a sumif formula that is based on a letter in column N. Right now my formula gives me a value error and I am trying to fix it. My current formula looks like this:
=IF($N$4:$N$51="S",SUMIF($E$4:$E$51,H91,$L$4:$L$51),"")
I am trying to say, if the letter in column n is S, then sumif this formula. My sumif formula is correct, just getting it to only add up the rows that have an s in column n is where it is wrong.

Excel or pentaho formula to get sum of distinct values in a column

I want to add a formula in penthao report to get sum of distinct values in a column. The formula of penatho is similar to excel. So how do i do that in excel. Please help.
I'm not sure if this can be done in a single cell, but it certainly is possible by adding in an extra column. For instance, if your range is A1:A25, you can type this formula in Cell B1 and drag it down to cell B25:
=IF(COUNTIFS(OFFSET($A$1,0,0,ROW(),1),$A1)=1,1,0)
This formula enters a 1 if the value in the range is the first occurrence, and 0 otherwise. The last step is to use a simple sumproduct for the final result:
=SUMPRODUCT($A$1:$A$25,$B$1:$B$25)

Excel formula: how to SUMIF values meeting certain condition until blank cell

I need to sum values in column A that meet certain criteria in column B until the next blank cell. The image (link above) shows the result I need: sums of all "A" for each three of the batches. I'm using this formula to calculate a total sum for each batch, and it works fine:
IF(A3="";SUM(A$1:A2)-SUM(C$1:C1);"")
But when I try to add SUMIF condition to this formula it doesn't work:
=IF(A3="";SUMIF(B:B;"A";A$1:A2)-SUM(D$1:D1);"")
What am I doing wrong?
Sum if requires that the range sizes be the same.
Put this in C2 and copy down:
=IF(B3="",SUMIF($B$2:$B2,"A",$A$2:$A2)-SUM($C$1:C1),"")
If the value in B in the next row is a null string then it will do the SUMIF, if not it returns a null string.
The SUMIF is being done on all the values from row 2 to the row in which the formula is being placed. We are then subtracting the already counted values above where the formula is placed in column C to get the new sum.

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.

Resources