Sum columns in Excel - excel

I want to sum the columns B-D given that column A equals "far".
Does anyone have a smooth formula for this calculation?
The answer should read : 10+10+3+12+2+5 = 42
A B C D
Far 10 10 3
Sol 10 21 12
Far 12 2 5
Sol 10 2 62
Gulf 10 4 0

SUMPRODUCT:
=SUMPRODUCT(($A$2:$A$6="Far")*$B$2:$D$6)
SUMIF:
=SUMIF(A:A,"Far",B:B)+SUMIF(A:A,"Far",C:C)+SUMIF(A:A,"Far",D:D)
Both have their advantages and disadvantages.
SUMPRODUCT is shorter formula and easier to maintain but it is an array type formula and the references need to be limited to the data set.
SUMIF is not array but it requires the ranges to be the same size and as such one must do a SUMIF for each column and then sum the results.

Related

Check if column values are increasing

I got an Excel sheet like:
A B C
1 L11 6
1 L21 10
1 L31 20
2 L12 5
2 L22 15
2 L32 23
I want to make a formula to check if each consecutive 3 values in column C are increasing. How can I do it?
I've tried to group by but was invain
If the value 6 is in C1, then you could put the following formula in D3: =AND(C3>C2, C2>C1)
Copy it down. If it's TRUE, it means that each consecutive 3 values in column C are increasing.
If you want to quantify the trend here I am using a simple formula to calculate the slope for the 3 numbers using the values in y axis.
Formula
=SLOPE(N2:N4,{1;2;3})

Select next higher number in array based on a minimum criteria

I have the following Excel spreadsheet:
A B C D
1 0 0.99 Minimum: 6
2 1 0.99 Input: 3
3 2 2.99 Result: 4.99
4 3 2.99
5 4 4.99
6 5 4.99
7 6 7.99
8 7 7.99
9 8 9.99
10 9 9.99
The formula in cell D3 is:
=LARGE(B$1:B$10,COUNTIF(B$1:B$10,">"&D2))
This formula selects the next highest number in the array in
Column B based on the input in cell D3.
For example:
If the input in cell D3 is 3 it will select
4.99 instead of 2.99.
All this works perfectly with the formula in cell D3.
However, now I want to insert a minimum criteria into this system
in cell D1.
For example: If the minimum is 6 the formula in cell D3 should notice it
and select 7.99 instead of 4.99.
Do you have any idea how to solve this issue?
Is there a way to do it without using an array formula?
You can use COUNTIFS to include multiple criteria, instead of your COUNTIF.
So in Cell D3 put the formula below:
=LARGE(B$1:B$10,COUNTIFS(B$1:B$10,">"&D2,B$1:B$10,">"&D1))
It means that the formula is searching for 2 criterias:
Cells Value is larger than value in Cell D2 (Input).
Cells Value is larger than value in Cell D1 (Minimum).
Using INDEX/MATCH you could restrict the range that's looked at, although I feel there's a better way:
=LARGE(INDEX($B:$B,MATCH($D$1,$A:$A,0)):INDEX($B:$B,COUNTA($A:$A)),COUNTIF(INDEX($B:$B,MATCH($D$1,$A:$A,0)):INDEX($B:$B,COUNTA($A:$A)),">"&$D$2))
You could place the INDEX/MATCH into a named range to make the formula shorter.

Sum row in Excel/Google Sheets based on Condition

It seems like this question should exist somewhere, but I can't seem to find it...exactly.
The most similar solution I can find requires the use of SUMIFS or SUMIF, which only seems to add up numbers in a column, not spanning multiple columns. Here's an example sheet with 2 rows:
A B C D E F G H ...
1 2015-01-01 0 1 6 12 45 12 5 ...
2 2016-01-01 256 43 13 35 134 135 12 ...
Now I'd like to have a cell somewhere that adds all of the cells in the row for 2015-01-01. My attempt looks like:
SUMIF(A1:A30,"2015-01-01", B1:BJ30)
But this only yields the sum of the column B, so 0 for the exact formula above or 256 if I were to do this for the year 2016.
When trying something with SUMIFS, I'm told that the criterion range's size should match the sum range size, which isn't the case because my criterion range is only the first column of dates.
How can I add all the values in a row if the first cell's date matches my criterion? It may be worthwhile to note that this is in Google Sheets, not Excel.
In both excel and googlesheets you can use a SUMPRODUCT, for example:
=SUMPRODUCT((A1:A30 = DATE(2015, 1, 1)) * B1:BJ30)
You can try either of these:
=if(A1=date(2015,1,1),sum(B1:F1),"")
=if(A1=A1,sum(B1:F1),"")

Summing a set of values based on cell content and row position

In the below table rows 2,3 and 4 have some details of a sporting event.
Range A2:C4 has a set of squad numbers and range D2:F4 has the details of who scored goals.
A B C D E F
1 Squad # Scorers
2 1 3 6 2 8 3
3 3 6 7 6 1
4 1 5 6 7 2 4
As an example squad # 6 has scored 8 goals based on the values equivalent position in the Squad section and relative to the Scorers range.
What formula will give me this total value and the equivalent total values for all squad numbers like the table below?
Some cells will be empty like F3.
1 9
3 14
5 2
6 8
7 0
A simple SUMPRODUCT function should take care of this.
=SUMPRODUCT($D$2:$F$4, --($A$2:$C$4=H2))
Fill down as necessary.
        
With only 3 games, the simplest way that I can see to do this would be to use 4 SUMIFS statements, as follows [assumes that your results data is in columns A & B, starting at row 5 and moving down; A5:A12 would hold the IDs for the different squads, and this formula would go in B5 and be copied down]:
=SUMIFS($D$2:$F$2,$A$2:$C$2,A5)+SUMIFS($D$3:$F$3,$A$3:$C$3,A5)+SUMIFS($D$4:$F$4,$A$4:$C$4,A5)
What it does is sum columns D:F, for row 1, row 2, and row 3, based on the fact that columns A:C for those rows match the appropriate squad ID.
This would be possible with an arguably shorter but more complex Array Formula, but with the data as you've presented it, I feel this is the clearest method.

I WANT CALCULATE SUM IN EXCEL

I HAVE A QUESTION ABOUT SUM IN EXCEL:
I have many rows in excel.
I want to calculate sum of each row in one formula
for example
A B C D E
2 3 5 6 8 24
4 5 6 8 9 32
BUT do not USE separate formula FOR EVER CALCULATION (FOR EXAMPLE =sum A1:D1)
CAN I USE WITH ONE FORMULA TO CALCULATE SUM OF EVERY ROWS
You do not have to manually enter the formula to calculate sum of every row.
In the first row you would input =SUM(A1:D1) (did you mean to include E1 as well?)
Then follow the instructions here to apply it the other rows

Resources