query help

buggy2

Board Regular
Joined
Feb 28, 2003
Messages
69
I am looking to create a query which will categorise the amount stored in a table per rating.

if amount < 0% then set the category field to "Less than 0"
if amount >0% but <10% then set the category field to "between 0% and 10%"
if amount >10% but <20% then set the category field to "between 10% and 20%"

Note amount, rating & category are fields in the same table
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
If you are looking to just return the phrase in a query, just create an expression in your query, something like:

expr1: IIf([Percentage]<0,"Less than zero",IIf([Percentage]<0.1,"between 0% and 10%",IIf([Percentage]<0.2,"between 10% and 20%","")))

If you actually want to update a category field, simply create an Update query, and use this expression in the "Update to" section of the category field.

Please note that you may need to change the "<" signs to "<=" in certain instances, depending on your needs (you didn't say what to do if the values were EXACTLY 0%, 10%, or 20%).
 
Upvote 0

Forum statistics

Threads
1,221,618
Messages
6,160,855
Members
451,674
Latest member
TJPsmt

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