Finding SUM except some columns - excel

Below is what I have.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ A + B + C + D + E + F + G + H + I + J + K +
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 50 +
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
To find the SUM of this row excluding Cell E I am using formulae as below.
=SUM(A1:D1)+SUM(F1:J1)
NOTE : Cell K have SUM.
Is there any alternate way??
Above is just an example however in my sheet there are around 100 columns and I need to exclude around 10-15 columns.

If you add a row like this:
Row2: yes yes yes yes no yes yes yes yes yes no ...
(being columns A:K)
Then the answer could be
=SUMIF(2:2,"yes",1:1)

I believe
=SUM(A1:J1)-E1
conveys your intention more clearly. (provided the excluded columns contain numbers, of course)

I do think that this is an alternate way
=SUM(A1:D1;F1:J1)

The common approach to address this problem in Excel is to apply the SUM function to the entire range and to substract the exception list out of it, again with the SUM function, this time with a discrete list of individual cells to sum:
=SUM(<range to sum>)-SUM(<exception cell 1>, <exception cell 2>, ...)
This applied to your current example of ~100 cells to sum with say 5 exceptions:
=SUM(A1:CV1)-SUM(E1,M1,Y1,AB1,BU1)
If you want to get your Excel spreadsheet more flexible to those columns exclusion, you may consider to define a named range on the discrete selection of your columns to exclude. If you use it in the substraction SUM formula, you will avoid to change the formula when additional columns need to be excluded : you will only need to change the named range specification.
=SUM(A1:J1)-SUM(A1:J1 Exclusion_List)
where Exclusion_List is a named range on the distinct columns to exclude

Related

Sum of the greatest value in one column, plus the sum of the other values in another column

Consider the following sheet/table:
A B
1 90 71
2 40 25
3 60 16
4 110 13
5 87 82
I want to have a general formula in cell C1 that sums the greatest value in column A (which is 110), plus the sum of the other values in column B (which are 71, 25, 16 and 82). I would appreciate if the formula wasn't an array formula (as in requiring Ctrl + Shift + Enter). I don’t have Office 365, I have Excel 2019.
My attempt
Getting the greatest value in column A is easy, we use MAX(A1:A5).
So the formula I want in cell C1 should be something like:
=MAX(A1:A5) + SUM(array_of_values_to_be_summed)
Obtaining the values of the other rows in column B (what I called array_of_values_to_be_summed in the previous formula) is the hard part. I've read about using INDEX, MATCH, their combination, and obtaining arrays by using parenthesis and equal signs, and I've tried that, without success so far.
For example, I noticed that NOT((A1:A5 = MAX(A1:A5))) yields an array/list containing ones (or TRUEs) for the relative position of the rows to be summed, and containing a zero (or FALSE) for the relative position of the row to be omitted. Maybe this is useful, I couldn't find how.
Any ideas? Thanks.
Edit 1 (solution)
I managed to obtain what I wanted. I simply multiplied the array obtained with the NOT formula, by the range B1:B5. The final formula is:
=MAX(A1:A5) + SUM(NOT((A1:A5 = MAX(A1:A5))) * B1:B5)
Edit 2 (duplicate values)
I forgot to explain what the formula should do if there are duplicates in column A. In that case, the first term of my final formula (the term that has the MAX function) would be the one whose corresponding value in column B is smallest, and the value in column B of the other duplicates would be used in the second term (the one containing the SUM function).
For example, consider the following sheet/table:
A B
1 90 71
2 110 25
3 60 16
4 110 13
5 110 82
Based on the above table, the formula should yield 110 + (71 + 25 + 16 + 82) = 304.
Just to give context, the reason I want such a formula is because I’m writing a spreadsheet that automatically calculates the electric current rating of the short-circuit protective device of the feeder of a group of electric motors in a house or building or mall, as required by the article 430.62(A) of the US National Electrical Code. Column A is the current rating of the short-circuit protective device of the branch-circuit of each motors, and column B is the full-load current of each motor.
You can use this formula
=MAX(A1:A5)
+SUM(B1:B5)
-AGGREGATE(15,6,(B1:B5)/(A1:A5=MAX(A1:A5)),1)
Based on #Anupam Chand's hint for max-value-duplicates there could also be min-value-duplicates in column B for corresponding max-value-duplicates in column A. :) This formula would account for that
=SUM(B1:B5)
+(MAX(A1:A5)-AGGREGATE(15,6,(B1:B5)/(A1:A5=MAX(A1:A5)),1))
*SUMPRODUCT((A1:A5=MAX(A1:A5))*(B1:B5=AGGREGATE(15,6,(B1:B5)/(A1:A5=MAX(A1:A5)),1)))
Or with #Anupam Chand's shorter and better readable and overall better style :)
=SUM(B1:B5)
+(MAX(A1:A5)-MINIFS(B1:B5,A1:A5,MAX(A1:A5)))
*COUNTIFS(A1:A5,MAX(A1:A5),B1:B5,MINIFS(B1:B5,A1:A5,MAX(A1:A5)))
The explanation works for bot solutions:
The SUM-part just sums the whole list.
The second line gets the max-value for column A and the corresponding min-value of column B for the max-values in column A and adds or subtracts it respectively.
The third line counts, how many times the corresponding min-value for the max-value occurs and multiplies it with the second line.
Can you try this ?
=MAX(A1:A5)+SUM(B1:B5)-MINIFS(B1:B5,A1:A5,MAX(A1:A5))
What we're doing is adding the max of A to all rows of B and then subtracting the min value of B where A is the max.
If you have Excel 365 you can use the following LET-Formula
=LET(A,A1:A5,
B,B1:B5,
MaxA,MAX(A),
MinBExclude, MINIFS(B,A,MaxA),
sumB1,SUMPRODUCT(B*(A=MaxA)*(B<>MinBExclude)),
sumB2,SUMPRODUCT(B*(A<>MaxA)),
MaxA +sumB1+sumB2
A and B are shortcuts for the two ranges
MaxA returns the max value for A (110)
MinBExclude filters the values of column B by the MaxA-value (25, 13, 82) and returns the min-value of the filtered result (13)
sumB1 returns the sum of the other MaxA values from column B (26 + 82)
sumB2 returns the sum of the values from B where value in A <> MaxA (71 + 60)
and finally the result is returned
If you don't have Excel 365 you can add helper columns for MaxA, MinBExclude, sumB1 and sumB2 and the final result

Excelc calculate a value based on dropdown list selection

Novice excel user here. I am working with Excel 2013
I have 11 cells in a row with dropdown lists. The drop down lists have 6 texts values:
Choose One
Exceptional
Excellent
Successfull
Needs Improvement
Unsuccessful
Depending one which is chosen they need to have values of 5 (exceptional) to 1 (Unsuccessful) and 0 being (Choose One). Some cells may only have Choose One (being not selected). I need to add the add up the total values of what is selected. So if 5 were "Selected", 4 were "Excellent" and 2 were Choose One, the total would be 31. I need to calculate the value of 31 / the number selected which in this case is 9 to equal 3.44. How do I create a formula in a cell to take all of that into consideration?
Thoughts?
Thanks in advance.
Assuming you have your dropdowns from A to K (11 cells),
and the values you indicated, you could use the formula
=COUNTIF(A2:K2,"Exceptional")*5 + COUNTIF(A2:K2,"Excellent")*4 + COUNTIF(A2:K2,"Successful")*3 + COUNTIF(A2:K2,"Needs Improvement")*2 + COUNTIF(A2:K2,"Unsuccessful")*1 + COUNTIF(A2:K2,"Choose One")*0 + COUNTIF(A2:K2,"")*0
to get the totals
you could use the fourmula
=COUNTA(A2:K2)
to give you the number of cells that have some data
then you could simply have the combined formula
=(COUNTIF(A2:K2,"Exceptional")*5 + COUNTIF(A2:K2,"Excellent")*4 + COUNTIF(A2:K2,"Successful")*3 + COUNTIF(A2:K2,"Needs Improvement")*2 + COUNTIF(A2:K2,"Unsuccessful")*1 + COUNTIF(A2:K2,"Choose One")*0 + COUNTIF(A2:K2,"")*0)/COUNTA(A2:K2)
to you give you the number you want

Excel - Include Row in Sum Based on Comparison to Following Row

Paging All Excel Wizards,
I am trying to see if there is a way to have a one-line SUMIF or something similar to sum up the following criteria in an Excel spreadsheet:
Sum the values of Column C if
If Column A = "Chizzle"
AND If Column B is >= Column B of the next row
Sample Data:
A B C
Type Level Value
__________________
Chizzle 1 23
Chizzle 2 10
Bobbles 3 1.5
Bobbles 3 2.6
Chizzle 2 5.5 <- Should Be counted
Cobbles 2 1
Chizzle 1 3.3 <- Should Be counted
I have tried using something like this:
=SUMIFS(C1:C1000,A1:A1000,"Chizzle", B1:B1000, ">=" & B2:B1001 )
Unfortunately the B2:B1001 part isn't working and it is selecting all values.
If there is a way to do this with a one line calculation, without having to add an additional column? That would be awesome but I'm not sure if it is possible.
Thanks!
Try this SUMPRODUCT():
=SUMPRODUCT(($A$2:$A$8="Chizzle")*($B$2:$B$8>=$B$3:$B$9)*($C$2:$C$8))

How to sum constants if the values of a row contian a specific value in excel?

I have the following row in excel:
12 4 12p 12a 12b
I need to sum this elements with their values from the legend.
12 = 12;
4 = 4;
12p = 12,5;
12a = 12,2;
12b = 12,3;
For example
=12 + 4 + 12,5 + 12,2 + 12,3
Any ideas?
If you have all the elements within one cell as a single string of text, the optimal approach would be to start by using text-to-column to split them up. So you'll have 12 in A, 4 in B, 12p in C, 12a in D, 12b in E. If that's not an option, I can show you string manipulations that can be an alternative.
You'll need to turn your "legend" into a look-up table, (perhaps on sheet2?), with column A having: p, a, b, etc.. and column B having the relative values.
Once that's done, place this formula on sheet1, in F column:
=A2+IFERROR(VLOOKUP(RIGHT(A2),Sheet2!$A:$B,2,FALSE),0)
Then drag it to the right 5 times, and it will have the values of the elements "translated".
You can sum the translated range easily.

Is it possible to add/subtract in one cell, and have it subtract/add in another cell that already has a value?

Is it possible to add/subtract in one cell, and have it subtract/add in another cell that already has a value?
I am thinking it may be a if function but I can not wrap my head around how I would write out the formula.
Let's say you have 2 columns B and C that already contain data.
And if you Add a number to B you want that number to be subtracted from C.
My recommendation is to write a macro that will work as follows:
First the user selects the two columns and then runs the macro
For each row
Cell c = getCell("C" + row);
double cval = c.Value;
c.type = FORMULA;
c.Formula = "=" + (cval + getCell("B" + row).Value) + "-B"+row;
c.Recalculate()
Example:
Original:
A B C
1 Gas 5 10
2 Air 8 12
Replace with:
A B C
1 Gas 5 =15-B1
2 Air 8 =20-B2
so you only change B, and the value of C is automatically calculated.

Resources