Select next higher number in array based on a minimum criteria - excel

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.

Related

FILTER function on column containing numbers, text and empty cells

0
A
B
C
1
Year
From
1974
2
2004
To
2005
3
2016
Result
3
4
1996
5
6
no info
7
1974
8
no info
9
10
11
12
In Cell C3 I want to count the rows in Column A where the year is
a) >= the value in Cell C1 AND
b) <= the value in Cell C2
Therefore, I implemented this formula:
=ROWS(FILTER($A$2:$A$12,($A$2:$A$12>=C1))*($A$2:$A$12<=C2))
However, this formula returns 11 as result which is probably caused by the empty cells and the no info input in Column A.
To avoid that those inputs are considered in the count of the rows I tried to go with this:
=ROWS(FILTER($A$2:$A$12,($A$2:$A$12>=C1))*($A$2:$A$12<=C2)*($A$2:$A$12<>"")*($A$2:$A$12<>"no info"))
However, this formula still returns 11 as result.
How do I have to modify it to get the correct values?
What about COUNTIFS()? Try-
=COUNTIFS(A:A,">="&C1,A:A,"<="&C2)
and with FILTER() try-
=ROWS(FILTER($A$2:$A$12,($A$2:$A$12>=C1)*($A$2:$A$12<=C2)))
You've put double close brackets )) too early in your formula, ending the Filter() function and then putting additional conditions outside of it.
Change the formula to
=ROWS(FILTER($A$2:$A$12,($A$2:$A$12>=C1)*($A$2:$A$12<=C2)*($A$2:$A$12<>"")*($A$2:$A$12<>"no info")))

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

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.

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

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

PercentileIF Excel (or rangeif)

A B
1 5
2 10
2 15
3 20
I want to calculate percentile for a column of values B if A is equal say 2. That's I want to get range of B2,B3 and calculate percentile of this.
So basically the question is: how do I select range in one column with the checking with another column?
I.e. it works perfectly with SumIf and CountIf, I just need the same with PercentileIf. Thx!
This will give you the 25th percentile of A1:A6 for all cells where the value in B1:B6 equals 2:
=PERCENTILE.INC(IF(B1:B6=2,A1:A6,""),0.25)
It's an array formula and must be entered with Ctrl-Shift-Enter.

Resources