Grouping values in excel, IF AND statement

coffee<3

New Member
Joined
Jul 18, 2013
Messages
8
Hi!

First of all: I'm very new to excel so please be patient and just ask if you don't understand the question.

The problem.
I have a large excel table (around 10 000 rows) and I would like to create a graph that shows how many of certain products are in a certain price range. So for example, I would like to be able to see how many products cost between $10000 and $20000.

The columns are: Product, Price, Date.

So what I was thinking of doing is creating a separate column with an IF/AND statment that checks if a price is within a range and then returns the range.

For example: =IF(All!I2<=9999;"0-9999";IF(AND(All!I2>=10000;ALL!I2<=19999);"10000-19999")

However, I have a lot of ranges so it would be a very long nested IF AND statement, is there another way of doing this? I've tried a pivot table and I know i can group values in it, but as I update my table, the pivot table ads new items outside the groups so I need to regroup them which takes a long time.
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Hi! What would be different by using vlookup? Wouldn't i still need to set up all the conditions in the same way?

The conditions for the ifs are as above, one condition for each "range" or "category", 100-200 and 201-300 and so on, the max price category is 500 000, so i would need a lot of nested if statements to cover all the different ranges.
 
Upvote 0
??? no understanding. Your if statement only has two that I'm seeing. This is what I was seeing

Excel 2010
ABCDE
19Tables
20099990-9999
211000019999910000-19999
22
2350000-9999
241500010000-19999
2525000-9999
Sheet1
Cell Formulas
RangeFormula
B23=VLOOKUP(A23,$C$20:$E$21,3)
 
Upvote 0
Sorry for beeing so unclear.
The if statement only has two right now, but if i want to create more i would need to add more, so I was wondering if there was an easier way to do this, instead of having to create an if statement with 50 different statements in it.

For example:


Product | Price | Date (these are the columns)

Rice | 200 | 2013-04-22
Meat | 100 | 2012-04-21
Peas | 140 | 2012-03-22
Chicken | 300 | 2003-04-22


So what i want to do is to see how many products cost between 100-110, 111-120 and so on. The solution I've come up with is to check if the value in the price column is between the values i want to categorize them in. This means that if i want to categorize them by 10s i need a lot of if statements for it.

Example: IF price<=100 return "0-100", if price>=101 AND price<150 return "101-150".

As you can see from the example above, as soon as i want to add another price category, lets say "300-400" i would need to add a new if and statement, and since the prices range from 10000 to 1 000 000 it will get quite boring to write so many if statements. Therefore I was wondering if there was a way where I could just select a column and simply "group by" and then select the range i would like, for example, every 10 000 or something.

By the way, how did you make the excel table in the reply?
 
Upvote 0
I've created an example table to try to explain.

Product

<tbody>
</tbody>
Price

<tbody>
</tbody>
Organic?

<tbody>
</tbody>
Olive oil extra virgin

<tbody>
</tbody>
19
Yes
Olive oil standard

<tbody>
</tbody>
12No
Olive oil greek

<tbody>
</tbody>
15No
Flaxeed oil standard

<tbody>
</tbody>
12Yes
Palm oil sour

<tbody>
</tbody>
16Yes
Flaxeed oil Gold

<tbody>
</tbody>
10No
Flaxeed oil Platinum

<tbody>
</tbody>
9Yes
Palm oil organic

<tbody>
</tbody>
14Yes
Palm oil sour

<tbody>
</tbody>
1110

<tbody>
</tbody>


So what i'm trying to do is to see "how many of my product costs between $1 to $10?" Sure with a table this small it's easy, but i've a lot of different products so I would like to create a separate column where i can group them into larger groups and then easily create a graph that counts the group column. That way i could easily see that I have 400 products that cost between $1 to $10. Then I would also like to group products into categories, for example it would be nice to see how many of my products are olive oil based?

The solution i have is: =IF(B2<=10;"1 to 10";IF(AND(B2>=11;B2<=15);"11 to 15";IF(AND(B2>=16;B2<=20);"16-20")IF(B2>20;">20")))

The problem with this solution is that my price range is quite big, so I will need a lot of nested if statements to cover it all. Therefore i'm looking for an easier way to do this, grouping by value. It would also be nice to see a way to group the products by name, something "if contains olive return "olive oil based".

Hope this description is better than my previous ones.
 
Upvote 0
would still work with a vlookup

Excel 2010
ABCD
1ProductPriceOrganic?Range
2Olive oil extra virgin19Yes16 - 20
3Olive oil standard12No11 - 15
4Olive oil greek15No11 - 15
5Flaxeed oil standard12Yes11 - 15
6Palm oil sour16Yes16 - 20
7Flaxeed oil Gold10No0 - 10
8Flaxeed oil Platinum9Yes0 - 10
9Palm oil organic14Yes11 - 15
10Palm oil sour111011 - 15
Sheet1
Cell Formulas
RangeFormula
D2=VLOOKUP(B2,$K$2:$L$14,2)


Excel 2010
KL
1Table
200 - 10
31111 - 15
41616 - 20
52121 - 25
62626 - 30
73131 - 35
83636 - 40
94141 - 45
104646 - 50
115151 - 55
125656 - 60
136161 - 65
1466Over 66
Sheet1
Cell Formulas
RangeFormula
L3=K3 &" - "&K4-1
K5=+K4+5
 
Upvote 0
Thank you soo much! This is exactly what I was looking for! Sorry for being a bit unclear at first.
 
Upvote 0
Your welcome. It was the same solution I offered before just didn't make it clear I'm guessing.:) Thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,272
Messages
6,123,981
Members
449,138
Latest member
abdahsankhan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top