I want to get the sum of values represented by 1,2,3,4
eg: =SUMIF(D5:D23,"1",G5:G23)+SUMIF(D5:D23,"2",G5:G23)+SUMIF(D5:D23,"3",G5:G23)+SUMIF(D5:D23,"4",G5:G23)
How can I do this operation? Please help me.
You want to use SUMIFS:
=SUMIFS(G5:G23,D5:D23,">0",D5:D23,"<5")
You want to sum all values from G5:G23 where the value from D5:D23 is greater than 0 and less than 5. So you require 2 criteria. >0 and <5.
Here is the function:
SUMIFS(sum_range,criteria_range1,criteria1,sum_range,[criteria_range2,criteria2],...)
Example:
Edit
Is think you want a vertical lookup - VLOOKUP()
Formulas:
G6: =VALUE(VLOOKUP(D6,$B$25:$E$30,2,FALSE))
H6: =IFERROR(IF(SEARCH("Valve",VLOOKUP(D6,$B$25:$E$30,3,FALSE))>0,$D$23,0),0)
I6: =E6*$D$22
J6: =SUM(G6:I6)
Now select G6:J6, grab the handle at the bottom right, and drag to fill rows G7:J7 to G20:J20.
Now sum up all the columns.
Here is the file completed: http://www.filedropper.com/wpmccardiocosts_1
You should check this out, it is very handy: http://www.mbaexcel.com/excel/tutorial-how-to-decide-which-excel-lookup-formula-to-use/
It may be simpler to use an array entered formula using SUM and IF:
=SUM(IF(D3:D23={1,2,3,4},G3:G23))
entered using [ctrl]+[shift]+[enter] (an array formula)
This will allow for use of many variables in place of 1,2,3,4 such as not continuous numbers, text ect.
Related
The data column contains four value:1,1,2,3 in a excel table,every data has its weight, weight for 1 is 0.9,weight for 2 is 0.8,weight for 3 is 0.7,i want the weighted sum.
1.Write the expression =IF($A2=1,0.9,IF($A2=2,0.8,IF($A2=3,0.7))) in B2.
2.Drag the fill handle from B2 till B5.
3.Write the expression =sum(B2:B5) in B6.
I get the right sum in b6,can i delete B column and write a single expression in B1 to get weighted sum?That is to say,merge step1,step2,step3 into a one single expression?
A different SUMPRODUCT can be used for differing weights:
=SUMPRODUCT(CHOOSE(A2:A5,0.9,0.8,0.2))
Note that this is an array formula and will need to be confirmed with CTRLSHIFTENTER
Use SUMPRODUCT:
=SUMPRODUCT(1-(A2:A5*0.1))
If you want to hard code the values then I suggest using INDEX/MATCH:
=SUMPRODUCT(INDEX({0.9,0.8,0.2},MATCH(A2:A5,{1,2,3},0)))
Then you can change the arrays to anything you like.
I want to get the count of cells used in an excel function.
For example say I have a sum function ='CV'!D11+Farmer!D11+'County'!D11+Rt!D11+WT!D11+'Country'!D11
I need a function that will tell me how many cells were used to get the total sum. In this case it is 6. The tricky part is if one of the cells used is blank I do not want it counted. For instance say cell D11 on the Farmer sheet is blank I do not want it counted in the total. So the total should be 5.
Use COUNT:
=COUNT('CV'!D11,Farmer!D11,'County'!D11,Rt!D11,WT!D11,'Country'!D11)
It will only count the cell if it has a number
You should really try to collate all your data in to a single sheet before running calculations. For the sake of example, I'll assume you have it in the range A1:A5, then you can add handling of the various cases using array formulas:
Get the count of non-empty cells (the ISBLANK function is untrustworthy in my experience): {SUM(IF(LEN(A1:A5)>0,1,0))}
Get the sum of those cells: SUM(A1:A5)
(must use Ctrl+Shift+Enter to enter the formula as an array formula, you will know it worked if the formula shows like {IF(...)} with the curly brackets)
Because blank/missing values are treated implicitly as 0 in the SUM function, this case is simple. If you have other validations then you'd have to write an array formula for the summation as well. For example, only including numbers between a min and max threshold (e.g. if you want to exclude outliers):
{SUM(IF(AND(A1:A5 >= yourMinValue, A1:A5 < yourMaxValue), A1:A5, 0)}.
If I understand your question correctly, you want to literately count the number of cells used in a formula which in your example is summing 6 values from 6 different locations.
I used the following example to demonstrate my solution:
The sum of =A1+B1+C1+D1+E1+F1 is 10 where cell C1 has a 0 value in it but cell E1 is blank.
Using the following array formula I was able to count the number of cells that have a value other than 0:
=SUMPRODUCT(IFERROR(ABS(N(INDIRECT(TRIM(MID(SUBSTITUTE(RIGHT(FORMULATEXT(A3),LEN(FORMULATEXT(A3))-1),"+",REPT(" ",100)),100*ROW(INDIRECT("1:"&LEN(FORMULATEXT(A3))))-99,100)))))>0,0)*1)
Please note you MUST press Ctrl+Shift+Enter upon finishing the formula in the formula bar otherwise they will not function correctly.
The logic is to use a combination of TRIM+MID+SUBSTITUTE+RIGHT+FORMULATEXT+REPT+ROW+INDIRECT to extract the cell addresses from the original formula, then use INDIRECT to convert the cell address into the values stored in those cells, then use a combination of IFERROR+ABS+N to find out if any of these values are not 0, and lastly use SUMPRODUCT to add up all the TRUE results.
It is obvious that there are a couple limitations of my solution:
If your actual formula is not strictly in the form of A+B+C+D+E+F, then my SUBSTITUTE part of formula will need further modification;
The formula will treat cells containing 0 as blank and does not include them in the count.
Let me know if you have any questions. Cheers :)
How to use SUMIF formula in Excel cell that must sum over a given range and instead of finding for a single value, it should find multiple values?
For finding a single value, I use:
=SUMIF(A4:A100;"1";B4:B100)
Now I need to sum over if the column A holds 1 or 2, like:
=SUMIF(A4:A100;"1" OR "2";B4:B100)
The cell A1 will hold the criteria as a text, here it would be 1;2.
It should return same as
=SUMIF(A4:A100;"1";B4:B100) + SUMIF(A4:A100;"2";B4:B100)
but I need a formula that can take any number of criteria (1,2,3,... or more).
What's the syntax? I'm not able to use VBA here.
To sum for 1 or 2 try this version
=SUM(SUMIF(A4:A100;{1;2};B4:B100))
SUMIF will return an "array" of two results so you need SUM to sum that array for the total for 1 and 2
You can add as many numbers as you like e,g,
=SUM(SUMIF(A4:A100;{1;2;3;4};B4:B100))
or with numbers listed in a range like Z1:Z10
=SUMPRODUCT(SUMIF(A4:A100;Z1:Z10;B4:B100))
I don't think there is a way to do OR within a single statement like this. You can use SUMIFS for multiple conditions where all need to be true, but in this case you would just need to add together multiple SUMIF statements:
=SUMIF(A4:A100,"1",B4:B100)+SUMIF(A4:A100,"2",B4:B100)
Since "1" and "2" are mutually exclusive:
=SUMIF(A4:A100,"1",B4:B100)+SUMIF(A4:A100,"2",B4:B100)
i think you should define a range, let's say keys where you keep all values for which you want to sum. so in this range you keep 1 and 2 and can modyfy it whenever you want. then you add a flag column with formula IFERROR(IF(MATCH(A4,keys,0)>0,1,0),0) - now you have column in which 1 is for the values you want to sum.
this works with multiple text evaluation
=sumif(M4:M206,"Sat",O4:O206)+sumif(M4:M206,"Sun",O4:O206) // add here more + + +
I need to return a median of only a certain category on a spread sheet. Example Below
Airline 5
Auto 20
Auto 3
Bike 12
Airline 12
Airline 39
ect.
How can I write a formula to only return a median value of the Airline Categories. Similar to Average if, only for median. I cannot re-arrange the values. Thank you!
Assuming your categories are in cells A1:A6 and the corresponding values are in B1:B6, you might try typing the formula =MEDIAN(IF($A$1:$A$6="Airline",$B$1:$B$6,"")) in another cell and then pressing CTRL+SHIFT+ENTER.
Using CTRL+SHIFT+ENTER tells Excel to treat the formula as an "array formula". In this example, that means that the IF statement returns an array of 6 values (one of each of the cells in the range $A$1:$A$6) instead of a single value. The MEDIAN function then returns the median of these values. See http://www.cpearson.com/excel/arrayformulas.aspx for a similar example using AVERAGE instead of MEDIAN.
Make a third column that has values like:
=IF(A1="Airline",B1)
=IF(A2="Airline",B2)
etc
Then just perform a median on the new column.
Expanding on Brian Camire's Answer:
Using =MEDIAN(IF($A$1:$A$6="Airline",$B$1:$B$6,"")) with CTRL+SHIFT+ENTER will include blank cells in the calculation. Blank cells will be evaluated as 0 which results in a lower median value. The same is true if using the average funtion. If you don't want to include blank cells in the calculation, use a nested if statement like so:
=MEDIAN(IF($A$1:$A$6="Airline",IF($B$1:$B$6<>"",$B$1:$B$6)))
Don't forget to press CTRL+SHIFT+ENTER to treat the formula as an "array formula".
one solution could be to find a way of pulling the numbers from the string and placing them in a column of just numbers the using the =MEDIAN() function giving the new number column as the range
I have two columns of numbers. Both are 1 to 5. I want to count all the cells where the left column value equals the right column value AND the left column value equals a certain value.
I tried this:
=SUM(IF(W2:W13=X2:X13 AND W2:W13=4,1,0))
I've tried pressing Ctrl+Shift+Enter and it adds {} around the formula but that didn't help either.
I think it's the W2:W13 = 4 part that doesn't work
=COUNTIFS(W2:W13,"=4", X2:X13, "=4")
You can use the sumif() function:
SumIf( range, criteria, sum_range )
it will apply the criteria for each row in the range.
Edit: to count the matches, you can use sum_range = 1 or use the Countif() function suggested by Ben in his answer
Have you considered a third column (C) with the formula IF(A1=B1,1,0) and then summing that third column?
I'm not much of an Excel Expert, but didn't they craeted the COUNTIF(range, criteria) function for this?
Add a third column eg Z2:Z13 with this formula: IF(AND(W2=X2; W2=4); 1; 0)
Then sum that one.
I don't have Excel 2007. So here's how you can do it in Excel 2003:
=COUNT(IF((W2:W14=4)*(X2:X14=4),Y2:Y14))
Since you are looking for a specific value and the column next to it to be the same value, you can just compare both columns to the same value.
The trick to get this to work is after entering the formula you need to hit F2 to go into edit mode and then hit CTRL-SHIFT-ENTER which makes this formula an array formula. This will put {} around the entire formula. Without making this an array formula this formula won't work.
I found this information in the Excel help document titled Count how often a value occurs