Excel find bucket without nested IFs
up vote
0
down vote
favorite
I have to separate my data in category, say for example:
Category Minimum Maximum
A -100 -20
B -20 0
C 0 +20
D +20 +100
So if one data point is -50, it belongs to Category A.
One solution is to use nested IFs:
=IF(A1<-20,"A",IF(A1<0,"B",IF(A1<20,"C","D")))
But when the number of categories increases it becomes quite messy. Is there a better way to achieve the same?
microsoft-excel worksheet-function
add a comment |
up vote
0
down vote
favorite
I have to separate my data in category, say for example:
Category Minimum Maximum
A -100 -20
B -20 0
C 0 +20
D +20 +100
So if one data point is -50, it belongs to Category A.
One solution is to use nested IFs:
=IF(A1<-20,"A",IF(A1<0,"B",IF(A1<20,"C","D")))
But when the number of categories increases it becomes quite messy. Is there a better way to achieve the same?
microsoft-excel worksheet-function
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have to separate my data in category, say for example:
Category Minimum Maximum
A -100 -20
B -20 0
C 0 +20
D +20 +100
So if one data point is -50, it belongs to Category A.
One solution is to use nested IFs:
=IF(A1<-20,"A",IF(A1<0,"B",IF(A1<20,"C","D")))
But when the number of categories increases it becomes quite messy. Is there a better way to achieve the same?
microsoft-excel worksheet-function
I have to separate my data in category, say for example:
Category Minimum Maximum
A -100 -20
B -20 0
C 0 +20
D +20 +100
So if one data point is -50, it belongs to Category A.
One solution is to use nested IFs:
=IF(A1<-20,"A",IF(A1<0,"B",IF(A1<20,"C","D")))
But when the number of categories increases it becomes quite messy. Is there a better way to achieve the same?
microsoft-excel worksheet-function
microsoft-excel worksheet-function
asked Oct 19 '12 at 9:27
assylias
401313
401313
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
up vote
1
down vote
accepted
Assuming you have the table with categories in Y2:Y10 and the minimums in Z2:Z10 (with 20 not +20 and similar for all positive numbers) then you can use a LOOKUP formula
=LOOKUP(A1,Y$2:Y$10,Z$2:Z$10)
Assumes there are no gaps in the ranges, i.e. the maximum for each category is effectively assumed to be immediately beow the next minimum
You have inverted the 2 ranges in your formula, it should be=LOOKUP(A1,Z2:Z10,Y2,Y10)
- otherwise it works fine, thanks.
– assylias
Oct 19 '12 at 9:56
Yes you are correct, apologies.
– barry houdini
Oct 19 '12 at 10:37
add a comment |
up vote
0
down vote
Another solution could be using named ranges.
I would modify your example to this:
Category Minimum Maximum
Cat_A -100 -20
Cat_B -20 0
Cat_C 0 +20
Cat_D +20 +100
Then mark the data from Cat_A to +100, and use Make from selection
(On Formula Tab, Section Defined Names) - use make from left column.
The you will get 4 named ranges Cat_A, Cat_B, Cat_C and Cat_D, which you can use in your workbook for i.e. conditional formatting, unsing Min(Cat_A)
and Max(Cat_A)
as limits.
However, this solution is more an extention to the one of barry houdini.
add a comment |
up vote
0
down vote
I use this trick for equal data bucketing. Suppose you have data in A1:A100
range. Put this formula in B1:
=MAX(ROUNDUP(PERCENTRANK($A$1:$A$100,A1) *4,0),1)
Fill down the formula all across B column and you are done. The formula divides the range into 4 equal buckets and it returns the bucket number which the cell A1 falls into. The first bucket contains the lowest 25% of values.
Adjust the number of buckets according to thy wish:
=MAX(ROUNDUP(PERCENTRANK([Range],[OneCellOfTheRange]) *[NumberOfBuckets],0),1)
The Advantage
The advantage of this solution is that you do not have to worry about the min and max of each bucket. The min and max parameters will mysteriously adjust themselves keeping equal number of observation in each bucket.
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Assuming you have the table with categories in Y2:Y10 and the minimums in Z2:Z10 (with 20 not +20 and similar for all positive numbers) then you can use a LOOKUP formula
=LOOKUP(A1,Y$2:Y$10,Z$2:Z$10)
Assumes there are no gaps in the ranges, i.e. the maximum for each category is effectively assumed to be immediately beow the next minimum
You have inverted the 2 ranges in your formula, it should be=LOOKUP(A1,Z2:Z10,Y2,Y10)
- otherwise it works fine, thanks.
– assylias
Oct 19 '12 at 9:56
Yes you are correct, apologies.
– barry houdini
Oct 19 '12 at 10:37
add a comment |
up vote
1
down vote
accepted
Assuming you have the table with categories in Y2:Y10 and the minimums in Z2:Z10 (with 20 not +20 and similar for all positive numbers) then you can use a LOOKUP formula
=LOOKUP(A1,Y$2:Y$10,Z$2:Z$10)
Assumes there are no gaps in the ranges, i.e. the maximum for each category is effectively assumed to be immediately beow the next minimum
You have inverted the 2 ranges in your formula, it should be=LOOKUP(A1,Z2:Z10,Y2,Y10)
- otherwise it works fine, thanks.
– assylias
Oct 19 '12 at 9:56
Yes you are correct, apologies.
– barry houdini
Oct 19 '12 at 10:37
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Assuming you have the table with categories in Y2:Y10 and the minimums in Z2:Z10 (with 20 not +20 and similar for all positive numbers) then you can use a LOOKUP formula
=LOOKUP(A1,Y$2:Y$10,Z$2:Z$10)
Assumes there are no gaps in the ranges, i.e. the maximum for each category is effectively assumed to be immediately beow the next minimum
Assuming you have the table with categories in Y2:Y10 and the minimums in Z2:Z10 (with 20 not +20 and similar for all positive numbers) then you can use a LOOKUP formula
=LOOKUP(A1,Y$2:Y$10,Z$2:Z$10)
Assumes there are no gaps in the ranges, i.e. the maximum for each category is effectively assumed to be immediately beow the next minimum
answered Oct 19 '12 at 9:36
barry houdini
9,90411320
9,90411320
You have inverted the 2 ranges in your formula, it should be=LOOKUP(A1,Z2:Z10,Y2,Y10)
- otherwise it works fine, thanks.
– assylias
Oct 19 '12 at 9:56
Yes you are correct, apologies.
– barry houdini
Oct 19 '12 at 10:37
add a comment |
You have inverted the 2 ranges in your formula, it should be=LOOKUP(A1,Z2:Z10,Y2,Y10)
- otherwise it works fine, thanks.
– assylias
Oct 19 '12 at 9:56
Yes you are correct, apologies.
– barry houdini
Oct 19 '12 at 10:37
You have inverted the 2 ranges in your formula, it should be
=LOOKUP(A1,Z2:Z10,Y2,Y10)
- otherwise it works fine, thanks.– assylias
Oct 19 '12 at 9:56
You have inverted the 2 ranges in your formula, it should be
=LOOKUP(A1,Z2:Z10,Y2,Y10)
- otherwise it works fine, thanks.– assylias
Oct 19 '12 at 9:56
Yes you are correct, apologies.
– barry houdini
Oct 19 '12 at 10:37
Yes you are correct, apologies.
– barry houdini
Oct 19 '12 at 10:37
add a comment |
up vote
0
down vote
Another solution could be using named ranges.
I would modify your example to this:
Category Minimum Maximum
Cat_A -100 -20
Cat_B -20 0
Cat_C 0 +20
Cat_D +20 +100
Then mark the data from Cat_A to +100, and use Make from selection
(On Formula Tab, Section Defined Names) - use make from left column.
The you will get 4 named ranges Cat_A, Cat_B, Cat_C and Cat_D, which you can use in your workbook for i.e. conditional formatting, unsing Min(Cat_A)
and Max(Cat_A)
as limits.
However, this solution is more an extention to the one of barry houdini.
add a comment |
up vote
0
down vote
Another solution could be using named ranges.
I would modify your example to this:
Category Minimum Maximum
Cat_A -100 -20
Cat_B -20 0
Cat_C 0 +20
Cat_D +20 +100
Then mark the data from Cat_A to +100, and use Make from selection
(On Formula Tab, Section Defined Names) - use make from left column.
The you will get 4 named ranges Cat_A, Cat_B, Cat_C and Cat_D, which you can use in your workbook for i.e. conditional formatting, unsing Min(Cat_A)
and Max(Cat_A)
as limits.
However, this solution is more an extention to the one of barry houdini.
add a comment |
up vote
0
down vote
up vote
0
down vote
Another solution could be using named ranges.
I would modify your example to this:
Category Minimum Maximum
Cat_A -100 -20
Cat_B -20 0
Cat_C 0 +20
Cat_D +20 +100
Then mark the data from Cat_A to +100, and use Make from selection
(On Formula Tab, Section Defined Names) - use make from left column.
The you will get 4 named ranges Cat_A, Cat_B, Cat_C and Cat_D, which you can use in your workbook for i.e. conditional formatting, unsing Min(Cat_A)
and Max(Cat_A)
as limits.
However, this solution is more an extention to the one of barry houdini.
Another solution could be using named ranges.
I would modify your example to this:
Category Minimum Maximum
Cat_A -100 -20
Cat_B -20 0
Cat_C 0 +20
Cat_D +20 +100
Then mark the data from Cat_A to +100, and use Make from selection
(On Formula Tab, Section Defined Names) - use make from left column.
The you will get 4 named ranges Cat_A, Cat_B, Cat_C and Cat_D, which you can use in your workbook for i.e. conditional formatting, unsing Min(Cat_A)
and Max(Cat_A)
as limits.
However, this solution is more an extention to the one of barry houdini.
answered Oct 19 '12 at 10:01
Jook
1,46021629
1,46021629
add a comment |
add a comment |
up vote
0
down vote
I use this trick for equal data bucketing. Suppose you have data in A1:A100
range. Put this formula in B1:
=MAX(ROUNDUP(PERCENTRANK($A$1:$A$100,A1) *4,0),1)
Fill down the formula all across B column and you are done. The formula divides the range into 4 equal buckets and it returns the bucket number which the cell A1 falls into. The first bucket contains the lowest 25% of values.
Adjust the number of buckets according to thy wish:
=MAX(ROUNDUP(PERCENTRANK([Range],[OneCellOfTheRange]) *[NumberOfBuckets],0),1)
The Advantage
The advantage of this solution is that you do not have to worry about the min and max of each bucket. The min and max parameters will mysteriously adjust themselves keeping equal number of observation in each bucket.
add a comment |
up vote
0
down vote
I use this trick for equal data bucketing. Suppose you have data in A1:A100
range. Put this formula in B1:
=MAX(ROUNDUP(PERCENTRANK($A$1:$A$100,A1) *4,0),1)
Fill down the formula all across B column and you are done. The formula divides the range into 4 equal buckets and it returns the bucket number which the cell A1 falls into. The first bucket contains the lowest 25% of values.
Adjust the number of buckets according to thy wish:
=MAX(ROUNDUP(PERCENTRANK([Range],[OneCellOfTheRange]) *[NumberOfBuckets],0),1)
The Advantage
The advantage of this solution is that you do not have to worry about the min and max of each bucket. The min and max parameters will mysteriously adjust themselves keeping equal number of observation in each bucket.
add a comment |
up vote
0
down vote
up vote
0
down vote
I use this trick for equal data bucketing. Suppose you have data in A1:A100
range. Put this formula in B1:
=MAX(ROUNDUP(PERCENTRANK($A$1:$A$100,A1) *4,0),1)
Fill down the formula all across B column and you are done. The formula divides the range into 4 equal buckets and it returns the bucket number which the cell A1 falls into. The first bucket contains the lowest 25% of values.
Adjust the number of buckets according to thy wish:
=MAX(ROUNDUP(PERCENTRANK([Range],[OneCellOfTheRange]) *[NumberOfBuckets],0),1)
The Advantage
The advantage of this solution is that you do not have to worry about the min and max of each bucket. The min and max parameters will mysteriously adjust themselves keeping equal number of observation in each bucket.
I use this trick for equal data bucketing. Suppose you have data in A1:A100
range. Put this formula in B1:
=MAX(ROUNDUP(PERCENTRANK($A$1:$A$100,A1) *4,0),1)
Fill down the formula all across B column and you are done. The formula divides the range into 4 equal buckets and it returns the bucket number which the cell A1 falls into. The first bucket contains the lowest 25% of values.
Adjust the number of buckets according to thy wish:
=MAX(ROUNDUP(PERCENTRANK([Range],[OneCellOfTheRange]) *[NumberOfBuckets],0),1)
The Advantage
The advantage of this solution is that you do not have to worry about the min and max of each bucket. The min and max parameters will mysteriously adjust themselves keeping equal number of observation in each bucket.
answered Nov 28 at 10:47
Przemyslaw Remin
7117
7117
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f489824%2fexcel-find-bucket-without-nested-ifs%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown