I have found that using the SUM() function to add a column of calculated values provides a different result than using the SUM() function against raw values. The following screen shots show a 1cent discrepancy between the sum of two columns that appear identical, except one is a calculated column and the other is raw data entry:
Note sum on column c is 1 cent different than column d
See the sum formula in row 22 is a simple sum
This is because the calculated values are not rounded to the 2nd decimal, they are just shown that way. But some of numbers may show 9.98 but really be 9.978.
If you want to see what I mean increase the decimal shown in those cells to four or more places.
To avoid this you can wrap the formulas in the range with =ROUND(...,2), where he ... is your formula. This will round the results to two places and then the two sums will match.
Related
Is there a way that you can use sum() in excel and that sums up x amount of columns depending on number given in another cell.
See below for example
Example of how it's today
In this picture I have columns B:M were I put in Actual figures.
And in columns T:AE I have budget figures.
In this example I have actual figures JAN-MAY and would like to compare them vs budget JAN-MAY.
How I do today is that I go in to column AF and drag so it's =SUM(T6:X6) so it only takes T:X in this case.
But I would like that cell AF has a formula in it were it looks at cell AH:3 and sees that it's number 5.
Therefore AF should sum(T;U;V;W;X(5columns))
Hope you understand my problem and have a solution!! :)
You can use the OFFSET function to determine the number of columns to SUM. In your example, AH3 is your offset amount.
In AF6 you can place this formula:
=SUM(T6:OFFSET(T6,0,AH3-1))
Which breaks down to
=SUM(T6:OFFSET(Start at T6, Offset 0 rows, Offset columns the value of AH3 and subtract one for a total of five columns))
So I have two columns: A&B.
In one calculation I summed up each column then calculated the difference: SUM(A)- SUM(B) and got ~16M
In another calculation I found the difference between each line item and then summed that. So essentially SUM OF (A1-B1),(A2-B2),etc. Where I dragged the subtraction formula down to the end of the columns and just did the sum of that column. I got ~17M
Why are the not equal?
As I stated in the title, I want to calculate the sum of the first n% rows in a filtered column. The total numbers of rows in the column varies due to the filtering options, so my formula must work with different values of n.
For example :
In column A, I have 10 rows that contain values from 10 to 1 ( I sorted them from largest to smallest ).
In column B, I have 10 corresponding rows that contain 2 names: 4 of them contain the value "Tom", six of them contain the value "Jerry". When I filter the whole table and select only the rows that contain the value "Jerry", I want to be able to calculate the sum of the first 20% of the corresponding 6 number values.
This could work without any filtering if you want.
With criteria for column B in E1 and percentage you looking for in F1 with the assumption we want to round up the percentage to integers.
So formula in D1:
=SUMPRODUCT(LARGE((B2:B11=E1)*(A2:A11),ROW(A1:INDEX($A:$A,ROUNDUP(COUNTIF(B2:B11,E1)*F1,0)))))
So, without your data, I came up with this, edit to suit your situation...
So, based on the comment, I did a second version:
The helper column in col C is used with sumproduct to give the result...
You can use the percentile function in AGGREGATE with SUMIFS to do what you want:
=SUMIFS(A:A,B:B,"Jerry",A:A,">="&AGGREGATE(16,7,A1:A10/(B1:B10="Jerry"),0.8))
If you want to use the filter to do the decision:
=SUMPRODUCT(SUBTOTAL(3,OFFSET(A1,ROW(A2:A10)-1,,1))*(A2:A10>=AGGREGATE(16,7,A2:A10,0.8)),A2:A10)
How can I test to make sure that the values between two cells are both non-zero?
This may be an exercise of my rustiness in certain areas of math but I have two columns of values in an excel spreadsheet. In a third column to the right, I'm taking 80% of one and 20% of another and getting the sum. However, this is throwing off the calculation I'm trying to do often because the value in several cells is zero in one but not the other. How can I only apply the 80% or 20% when both values are not zero?
If your columns are A and B, the following will work in column C:
=IF(AND(A1<>0,B1<>0),(0.8*A1)+(0.2*B1),"A value equals zero")
In plain language:
If A and B are both not equal to zero, apply the calculation.
Else, warn the user that a value in column A or B equals zero.
Edit:
In response to the comment:
=IF(AND(A1<>0,B1<>0),(0.8*A1)+(0.2*B1),SUM(A1:B1))
In plain language:
If A and B are both not equal to zero, apply the calculation.
Else, sum the two values. The sum is equal to the non-zero value in column A or B.
I'm having an issue getting accurate data from the SUMIF function. This appears to be caused by the SKU and Product name being identical however I don't understand why the selected range would be ignored.
SUMIF(G:K,A2,K:K) - Cell D2 is calling for the sum of K yet returning the sum result of K2:M2. All other results in D are correct.
SUMIF(G:K,A2,I:I) - If I change the formula in D to SUM I:I (text not a numeric field) the function returns the sum of K:K
Example file http://tempsend.com/013C2B6378
According to the documentation here the range to be summed starts at the top left of the sum range (K:K in your first example) but its size is given by the size of the criteria range (G:K in your example). So I think that's why you're getting extra columns summed in your result.
If you have multiple criteria involving different columns, you should be able to use SUMIFS.
So let's say your data sit in 8 rows (including the headings).
then you simply need to change your formula to say, look for B2 in column G OR in I, if true, then sum the values in K. Right?
put this formula in B2 and press ctrl+shift+enter to calculate the formula.
=SUM(IF(($G$2:$G$8=B2)+($I$2:$I$8=B2),1,0)*$K$2:$K$8)
then drag and fill down until the last cell.
obviously you need to adjust the ranges in the formula to adapt to your own data.
tell me if you get to the answer via this.