Formula to automatically subtract and multiply two rows over a variable number of columns - excel

I have the following sum in G4 =SUM((G2:G3)*$D$2) and in G6 I have =SUM(G4-G5), I then drag copy them for the duration denoted in C1. I'd like to change this so I have a single formula in H4 and H6 that will expand based on the value in C1.
I have something similar in another sheet that sums two adjacent cells together for the duration of a project but I just can't see how to modify it to work for the multiplication sum in H4 and the subtraction sum in H6 on this sheet. This is what I have in the other sheet =BYCOL(INDEX($1:$4,{3;4},SEQUENCE(1,D2,COLUMN(I:I))),LAMBDA(x,SUM(x)))
Here's the data I used:
Start Date End Date Length in Months Rate
01/01/2021 31/12/2021 12 £3,500
And:
Jan-21 Feb-21 Mar-21 Apr-21 May-21 Jun-21 Jul-21 Aug-21 Sep-21 Oct-21 Nov-21 Dec-21
Staff 2 3 2 1 6 2 1 2 5 5 3 2
Additional Staff 1 2 3 4
Costs £5,000 £7,000 £5,000 £2,000 £8,000 £7,500 £1,500 £7,000 £7,000 £15,000 £5,000 £2,000

I have the sum in G4 working using =BYCOL((INDEX($1:$4,{2;3},SEQUENCE(1,C2,COLUMN(G:G)))),LAMBDA(x,SUM(x*($D$2)))).
And for G6 I have a workaround by multiplying costs row from G5 by -1 which makes the following work =BYCOL((INDEX($1:$5,{4;5},SEQUENCE(1,C2,COLUMN(G:G)))),LAMBDA(x,SUM(x)))
Ideally I wouldn't have to multiply the costs by -1 so it'd be great to hear of alternative solutions.

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})

Formula to calculate a sum of differences and count them

I have the following Excel spreadsheet:
A B C D E F G H
1 Sales 500 700 600 450 550 600 500
2 Helper Row (Differences) 40% -14% -25% 22% 9% -17%
3 Helper Row (Counts) 0 0 1 0 0 0
4 Count Result 1
In Row 1 you can see the sales over different periods. In Row 2 the difference between the sales are displayed. (e.g. formula in C2=C1/B1-1).
In Row 3 the formula indicates 2-Following-Periods in which in total the sales drop by >-20%.
In the case above this applies to cell E3 because the sales in cell D2 drop by -14% and in the next period in cell E2 by -25% which makes a total drop of those two periods by -39%.
The formula I use in Row 3 is for example E3=IF(SUM(D2:E2)<-0.2,1,0).
Eventually, I use a sum function in cell B4 (B4=SUM(B3:H3)) to count how often the above described criteria is met.
All this works perfectly so far. However, my target now is to get rid of the Hepler Row 2 and Row 3.
Do you know a formula that gives me the count result which meets the above described criteria?
Assuming that your above demonstrated numbers are in cell B1:H1, you can use following formulae to achieve result without helper cells.
Array formula (CTRL+SHIFT+ENTER and not just ENTER)
=SUM((((C1:H1-B1:G1)/B1:G1)<-0.2)+0)
Or for normal ENTER
=SUMPRODUCT((((C1:H1-B1:G1)/B1:G1)<-0.2)+0)

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.

In excel, how can I split value in a cell and apply vlookup formula for each split value?

I have been struggling to find an answer for several hours and I am sort of giving up. Here is what I am doing in excel.
For each number (1 through 4) , I am assigning a code and a corresponding Score.
I am inputting this data starting from first row (A1 through C4)
Number Code Score
1 A 2
2 B 4
3 C 6
4 D 8
Input: Now, each person gets a number every week and my data is like this
Person Week1 Week2
Person1 3 (A10 is the cell) 4 (A11 is the cell)
My output: I am using vlookup to find the value for each week and get a score.
Person Week1 Week2
Person1 6 8
So to get 6, I am using the formula:
=VLOOKUP(A10,Complexity!A1:C4,3)
To get 8, I am using the formula:
=VLOOKUP(A11,Complexity!A1:C4,3)
So far so good. My problem is that , some week might have 2 values.
Example:
Person Week1
Person1 3,4 (A10 is the cell)
I am expecting the output score:
Person Week1
Person1 14
How can I split the values in the cell and apply vlookup formula for each time so i can get a total of 6 + 8
For A11, and assuming that any separator within that cell, if present, is only ever a single comma (no space), as in your examples:
=SUMPRODUCT(0+(ISNUMBER(FIND(","&Complexity!A$1:A$4&",",","&A11&","))),Complexity!C$1:C$4)
Copy down to give similar results for entries in A12, A13, etc. (though note that I made the reference to the Complexity sheet in the above absolute with respect to rows).
Regards

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