Excel formula for greater than but less than with several tiers - excel

I have a few hundred rows of data, and each has a number between 1 and 200, and I'd like to put them in categories of 1-5 depending on where that number is.
The categories look like this:
Zones Min Max
1 0 35
2 35 60
3 60 85
4 85 110
5 110 200
I want to assign it a Zone if it is greater than the Min, but less than the Max.
I have 2 formulas I've been working with to solve it. One is a nested IF AND statement:
=IF(A1<=35,1,IF(AND(A1<=60,A1>35),2,IF(AND(A1<=85,A1>60),3,IF(AND(A1<=110,A1>85),4,IF(AND(A1<=200,A1>110),2,"TOO BIG")))))
The 2nd formula attempts to use a SUMPRODUCT function:
=INDEX($C$2:$C$6,SUMPRODUCT(--(A1<=$E$2:$E$6),-- (A1>$D2:$D$6),ROW($2:$6)))
Rather than have to continue to adjust the numeric values manually, I set them as absolutes, which is why this formula is slightly different. The E column is the Max value set, and the D is the Min value set.
Any help would be appreciated!

Use this:
=MATCH(A1,{0,35,60,85,110})

Another way is to use VLOOKUP and you just need to set the min number:
=VLOOKUP(D2,$A$2:$B$6,2,1)
The key is the 4th parameter needs to set to 1 which means TRUE. It will find the closest value and return the zone for you.
But noticed that you have overlaps like 35 or 60 etc. that you will need to adjust your value column.

Related

Reverse MATCH with a non existing value

I have data in Excel in the following format:
Column A Column B
20/03/2018 300
21/03/2018 200
22/03/2018 100
23/03/2018 90
24/03/2018 300
25/03/2018 200
26/03/2018 100
27/03/2018 50
28/03/2018 90
29/03/2018 100
30/03/2018 110
31/03/2018 120
I would like to get the date where the minimum of B would never be under 99 again chronologically. It the example above, that would happen the 29th of March.
If I try to get it with: =INDEX(A:A,MATCH(99,B1:B12,-1)) the value returned is 22/03/2018 as it is the first occurrence found, searched from top to bottom.
In this case it would be perfect to be able to do a reverse match(e.g. a match that searches from bottom to top of the range) but this option is not available. I have seen that it is possible to do reverse matches with the lookup function but in that case I need to provide a value that is actually in my data set (99 would not work).
The workaround I have found is to add a third column like the following (with the minimum of the upcoming value of B going down) and index match on top it.
Column A Column B Column C
20/03/2018 300 50
21/03/2018 200 50
22/03/2018 100 50
23/03/2018 90 50
24/03/2018 300 50
25/03/2018 200 50
26/03/2018 100 50
27/03/2018 50 50
28/03/2018 90 90
29/03/2018 100 100
30/03/2018 110 110
31/03/2018 120 120
Is there a way of achieving this without a third column?
The AGGREGATE function is great for problems like these:
=AGGREGATE(14,4,(B2:B13<99)*A2:A13,1)+1
What are those numeric arguments?
14 tells the function to replicate a LARGE function
4 to ignore no values (this function can ignore error values and other things)
More info here. I checked it works below:
If your dates aren't always consecutive, you'll need to add a bit more to the function:
=INDEX(A1:A12,MATCH(AGGREGATE(14,6,(B1:B12<99)*A1:A12,1),A1:A12,0)+1)
=INDEX(A1:A12,LARGE(IF(B1:B12<=99,ROW(B1:B12)+1),1))
This is an array formula (Ctrl+Shift+Enter while still in the formula bar)
Builds an array of the row 1 below results that are less than or equal to 99. Large then returns the largest row number for index.

Divide excel column to N equal groups

I have a column with ordinal values. I want to have another column that ranks them in equal groups (relatively to their value).
Example: If I have a score and I want to divide to 5 equal groups:
Score
100
90
80
70
60
50
40
30
20
10
What function do I use in the new column to get this eventually:
Score Group
100 5
90 5
80 4
70 4
60 3
50 3
40 2
30 2
20 1
10 1
Thanks! (I'm guessing the solution is somewhere in mod, row and count - but I couldn't find any good solution for this specific problem)
If you don't care about how the groups are split for groups that aren't evenly divisible, you can use this formula and drag down as far as necessary:
= FLOOR(5*(COUNTA(A:A)-COUNTA(INDEX(A:A,1):INDEX(A:A,ROW())))/COUNTA(A:A),1)+1
Possibly a more efficient solution exists, but this is the first way I thought to do it.
Obviously you'll have to change the references to the A column if you want it in a different column.
See below for working example.

Excel function to choose a value greater than or less that a particular value in cell

I have a data set something like this
Units Price
1 15
100 10
150 9
200 8
50000 7
I need the output as Price with respect to quantity.
Example- If Input value is 90 it should give price as 15
If input is 210 it should give value as 8.
However,sadly I cannot use IF statement.
Thanks in advance.
You can use a combination of INDEX and MATCH
=INDEX(B1:B5,MATCH(lookup_value,A1:A5,1))
This assumes Units are in column A and Price is in column B
Make sure you understand both functions:
INDEX
MATCH - particularly the reason for the ,1) at the end
You can also use VLOOKUP. This is probably a bit easier although INDEX/MATCH is more versatile:-
=VLOOKUP(Lookup_value,$A$2:$B$6,2,TRUE)

Create a formula that returns a minimum date from a range based on cell values in another column

I am looking for a formula that will return the earliest date from a column, based on the contents of values in other cells. (Actually I want a Min and Max date, but am assuming the Max will be identical to any Min solution )I know I can return the date I want just by using MIN and specifying the range of cells I want, but I ideally want the formula to be dynamic. I have looked around and believe I possibly need to use a combination of index and match, but cant find any examples that use Min and Max. I have considered using dynamic named ranges to define my task groups, but that would mean having to define a static number of task groups, and there could be many task groups.
The sheet below shos some sample date on the left of the workbook, with the summary data on the right. The "hidden worker column" was an idea I had that I though might make the solution easier. So I want the summary data on the right to use either column A, or column B if its easier, to display the min and max dates based on the section number in column F - Is this possible without VBA?
#mthierer's link is good. If you wanted to remove the need to add a "helper column", you could try (data in A1:C10; summary table in E1:G2):
{=MIN(IF(ROUNDDOWN($A$1:$A$10, 0)=$E1, $B$1:$B$10))} (or {=MAX(...)} with $C$1:$C$10)
Note that you have to enter the formula as an array formula with CtrlShiftEnter.
Data (A1:C10):
1 23 57
1.1 42 91
1.2 35 100
1.3 39 80
1.4 28 51
1.5 30 96
2 33 52
2.1 11 73
2.2 48 80
2.3 16 59
Summary Results (E1:G2):
1 23 100
2 11 80

Excel: Find the minimal value in a column

An Excel table consists of two columns (e.g., A1:B5):
0 10
1 20
3 30
2 20
1 59
I need to get the minimal value in column B for which the corresponding value in column A is greater than zero. In the above example it should be 20.
I tried using various combinations of INDEX(), MIN(), IF(), ROW(), array formulas, etc. - but I just can't figure out how to do it. :-( Any help would be appreciated.
Grsm almost had it
if you enter the following formula in C1 as an array (Ctrl+Shift+End)
=MIN(IF(A1:A5>0,B1:B5))
That should do the trick.
I think you have to make an extra column..
A B C D
0 10 false 20
1 20 20
3 30 30
2 40 40
1 50 50
column C : =IF(A1>0;B1)
cell D1: =MIN(C1:C5)
You need to do it in 2 stages
First use the MIN function to find the minimum
Then take that answer and use the LOOKUP function to select the row and column that you need.
Check the "Minimum And Maximum Values In A Range" example in http://www.cpearson.com/Excel/excelF.htm (you can download the same as well from the same section)
HTH
This is not identical, but very similar: Excel VBA - Find minimum of list of values?

Resources