How to sum a column formula - excel

I have this Excel sheet in which I have many columns, and I need a sum formula applied to every one of them:
| | A | B | C | D | E |
| 1 | Products | Prod1 | Prod2 | Prod3 | Revenues |
| 2 | Price/u | 10 | 20 | 30 | -------- |
| 3 |Price Fixed| 5 | 10 | 2 | -------- |
| 4 |Sales | ----- | ----- | ----- | -------- |
| 5 | 2017 | 1 | 5 | 56 | ?????? |
| 6 | 2018 | 3 | 10 | 100 | ?????? |
| 7 | -------------------------------------------- |
| 8 | TOTAL | SUM() | SUM() | SUM() | -------- |
I was wondering how to calculate ?????. Indeed, it would look like:
=(B5 * B2 + B3) + (C5 * C2 + C3) + (D5 * D2 + D3), the problem is that I need to get that to Z.
Thanks!

You can use this formula:
=SUMPRODUCT(B5:Z5*B2:Z2 + B3:Z3)
SUMPRODUCT operates on arrays. It is here submitted a single array, so it just sums it up. This array is computed as:
element-wise product of the row vectors B5:Z5*B2:Z2
element-wise addition of row vector B3:Z3

You can also use an array formula and then sum the lot:
={SUM(B5:Z5*B2:Z2+B3:Z3)} not forgetting to do array formulae you use CTRL+SHIFT+ENTER

Related

How to reference cell in formula where result met condition

Is there a way to write a formula for Variation so that it always relates to the lastest cell where the Variation was greater than a threshold?
In the following table the denominator of the percentage changes if the absolute value of Variation is greater than 10%. The formulas were changed manually by me.
------------------------------------------
| Row | Value | Variation| Formula |
------------------------------------------
| 1 | 1,1608 | 0,0% | A2/ A$2 - 1 |
| 2 | 1,1208 | -3,4% | A3/ A$2 - 1 |
| 3 | 1,0883 | -6,2% | A4/ A$2 - 1 |
| 4 | 1,0704 | -7,8% | A5/ A$2 - 1 |
| 5 | 1,0628 | -8,4% | A6/ A$2 - 1 |
| 6 | 1,0378 | -10,6% | A7/ A$2 - 1 | <---- Abs. Variation > 10 %
| 7 | 1,0353 | -0,2% | A8/ A$7 - 1 | <---- Change denominator
| 8 | 1,0604 | 2,2% | A9/ A$7 - 1 |
| 9 | 1,0501 | 1,2% | A10/ A$7 - 1 |
| 10 | 1,0706 | 3,2% | A11/ A$7 - 1 |
| 11 | 1,0338 | -0,4% | A12/ A$7 - 1 |
| 12 | 1,0110 | -2,6% | A13/ A$7 - 1 |
| 13 | 1,0137 | -2,3% | A14/ A$7 - 1 |
| 14 | 0,9834 | -5,2% | A15/ A$7 - 1 |
| 15 | 0,9643 | -7,1% | A16/ A$7 - 1 |
| 16 | 0,9470 | -8,7% | A17/ A$7 - 1 |
| 17 | 0,9060 | -12,7% | A18/ A$7 - 1 | <---- Abs. Variation > 10 %
| 18 | 0,9492 | 4,8% | A19/A$18 - 1 | <---- Change denominator
| 19 | 0,9397 | 3,7% | A20/A$18 - 1 |
| 20 | 0,9041 | -0,2% | A21/A$18 - 1 |
------------------------------------------
Is it possible to write a formula where the denominator changes on a given condition?
All my attempts with Array formulas, MATCH, AGGREGATE etc. went to nowhere.
Here is another way:
Place zero in E2.
In E3:
=IF(E2<-0.1,B3/B2-1,B3*(E2+1)/B2-1)
So what I'm trying to do is to work out the denominator from the previous row. So
E2=B2/denominator-1
Re-arranging you get
Denominator=B2/(E2+1)
So in the regular case you divide by this denominator, otherwise you divide by B2.
If it's possible to add another column to your data, it is very possible to do this with one IF statement. Your formula for the formula row would be:
=A2/(E1-1)
Column E formula (starting at E2) would be:
=IF(ABS(C2)>10, A2, E1)
Where E1 would be:
=A2
since that is what you have by default in your first formula.

Determine range for one value in a column, use to run function over same range in another

Summary
I want to have a column in my spreadsheet that does 2 things.
1) In an ordered column, it will return the range where the column contains a specified value.
2) It will run a function (i.e., =SUM(), =AVERAGE(), etc.) over that same range in a different column.
Examples
Original
| NAME | VAL | FOO |
|-------|-----|-----|
| A | 3 | |
| A | 2 | |
| A | 4 | |
| A | 3 | |
| B | 2 | |
| B | 2 | |
| B | 1 | |
| C | 6 | |
| C | 5 | |
Average
I would want to get the average of VAL for each NAME. I would want the result to be:
| NAME | VAL | FOO |
|-------|-----|-----|
| A | 3 | 3 |
| A | 2 | 3 |
| A | 4 | 3 |
| A | 3 | 3 |
| B | 2 | 1.7 |
| B | 2 | 1.7 |
| B | 1 | 1.7 |
| C | 6 | 5.5 |
| C | 5 | 5.5 |
Sum
Another example would be to get the sum of VAL for each NAME.
| NAME | VAL | FOO |
|-------|-----|-----|
| A | 3 | 12 |
| A | 2 | 12 |
| A | 4 | 12 |
| A | 3 | 12 |
| B | 2 | 5 |
| B | 2 | 5 |
| B | 1 | 5 |
| C | 6 | 11 |
| C | 5 | 11 |
Having "NAME" ordered makes it easy. If "NAME" is in A1. Enter this into C2 for the sum, then fill down:
=IF(A2=A3,C3,SUMIF($A$2:A2,A2,$B$2:B2))
Enter this into C2 for the average, then fill down:
=IF(A2=A3,C3,AVERAGEIF($A$2:A2,A2,$B$2:B2))
Note that the result in C2 won't be what you want until you fill down.
Update for MAXIF
If you don't have Excel 2016, you'll have to use an array formula (commit with ctrl+shift+enter):
=IF(A2=A3,C3,MAX(IF($A$2:A2=A2,$B$2:B2)))

excel to count the duplicate in a column

I need to find the duplicates in this way.please help me
--|-----|-------|-------|-------|-------
| A | B | C | D | E |
--|-----|-------|-------|-------|------|
1 | 1 | a1 | 1 | | |
2 | 2 | a2 | 1 | | |
3 | 3 | a3 | 1 | | |
4 | 4 | a5 | 1 | | |
5 | 5 | a1 | 2 | | |
6 | 6 | a2 | 2 | | |
7 | 7 | a1 | 3 | | |
8 | 8 | a3 | 2 | | |
9 | 9 | a1 | 4 | | |
10| 10 | a1 | 5 | | |
----------------------------------------
For ex: Individual duplicate B column- In B column "a1" - 5 duplicate values totally,
check the c column i need the output like that
You should be using this formula in Column C
=COUNTIF($B$1:$B1,B1)
Let me know if it does not work.
You want a cumulative sum of the number of occurences of the value in column B. You can do that by inserting the following formula in C2:
=COUNTIF("$A$2:A2; A2)
You then drag in vertically, as far as you like. The result should be something like this:
| "C"
2 | =COUNTIF("$A$2:A2; A2)
3 | =COUNTIF("$A$2:A3; A3)
4 | =COUNTIF("$A$2:A4; A4)
And so on, and so on...
In column C kindly enter below formula.
=COUNTIF($C$1:C1,C1)
And drag it to last cell c10
Regards
Lalit.M

Excel: Give scores based on range, where max = 1 and min = 10

I have following problem:
I want to give scores to a range of numbers from 1-10 for example:
| | A | B |
|---|------|----|
| 1 | 1209 | 1 |
| 2 | 401 | 7 |
| 3 | 123 | 9 |
| 4 | 49 | 10 |
| 5 | 30 | 10 |
(Not sure if B is 100% correct but roughly)
I got the B values with
=ABS(CEILING(A1;MAX($A$1:$A$32)/10)*10/MAX($A$1:$A$32)-11)
It seems to work but if I for example take numbers like
| | A | B |
|---|------|----|
| 1 | 100 | 1 |
| 2 | 90 | 2 |
| 3 | 80 | 3 |
| 4 | 70 | 4 |
| 5 | 50 | 6 |
But I want 50 to be 10.
I would like to have it scalable so I can do it with a 1-10 or 1-100 or 5-27 or whatever scale and with however many numbers in the list and whatever numbers to score from.
Thanks!
Use this formula:
=$E$1 + ROUND((MIN($A:$A)-A1)/((MAX($A:$A)-MIN($A:$A))/($E$1-$E$2)),0)
It is scalable. You put the max and min in E1 and E2.

Transform values without VBA but with Index and Match

I'm trying to find a solution without macros in excel for following problem:
There is a table containing ratings of a student for different time periods.
So the rating of the student with ID=1 was 1 from January to April and 3 from Mai to June.
Two other students had a constant ranking (6 and 9) from January to June
| A | B | C |D |
---| ----|------------|------------|-------|
1 | ID | START | END |RANKING|
2 | 1 | 01.01.2014 | 30.04.2014 | 1 |
3 | 1 | 01.05.2014 | 30.06.2014 | 3 |
4 | 2 | 01.01.2014 | 30.06.2014 | 6 |
5 | 3 | 01.01.2014 | 30.06.2014 | 9 |
Next table contains IDs (y axis) and Months (x axis)
| F | G | H | I | J | K | L |
---| ----|--------|--------|--------|--------|--------|--------|
1 | ID | 201401 | 201402 | 201403 | 201404 | 201405 | 201406 |
2 | 1 | | | | | | |
3 | 2 | | | | | | |
4 | 3 | | | | | | |
And I wish to feel this second table like this:
| ID | 201401 | 201402 | 201403 | 201404 | 201405 | 201406 |
| ----|--------|--------|--------|--------|--------|--------|
| 1 | 1 | 1 | 1 | 1 | 3 | 3 |
| 2 | 6 | 6 | 6 | 6 | 6 | 6 |
| 3 | 9 | 9 | 9 | 9 | 9 | 9 |
I tried to use Index and Match, but without any good results because I haven't found a posibility to use IF (if (
Could anybody help?
You can get what you're looking for with SUMPRODUCT
Given the layout you provided, this formula should work when put in G2 and filled down and over
=SUMPRODUCT(--($A:$A=$F2),--($B:$B<=G$1),--($C:$C>G$1),$D:$D)
That looks in column A for an ID matching F2, then for every one it finds of those:
It checks the date in column B against the date in G1
It checks the date in column C against the date in G1
If all criteria match, it returns the value in Column D
This assumes you only have one entry for each period, otherwise it will sum them.
Also, you can use SUMIFS, it's a little less easy to read but I think it's slightly more efficient than SUMPRODUCT (I'm not positive, just anecdotal evidence from usage)
=SUMIFS($D:$D,$A:$A,"="&$F3,$B:$B,"<="&G$1,$C:$C,">"&G$1)
It does the exact same thing, just with different syntax.

Resources