Aged Date Range Formula

I am creating an aged ticket report for my manager.  I first calculated the Days open by using the formula =NOW()-A2, where cell A2 is the created date in yyyy/mm/dd format, which is rounded up to the nearest number.  I then want to calculate the date range each ticket is open,  0-3 days open, 4-7 days open, 8-15 days open, 16-30 days open, 31-60 days open, 61-120 days open and >120.  Both of these formulas are in cells q and R. Here is the formula:

=IF(Q2>120,"120",IF(Q2>60,"61-120",IF(Q2>30,"31-60",IF(Q2>15,"16-30",IF(Q2>7,"8-15",IF(Q2>3,"4-7","0-3"))))))

When I run the formula it works great, but when I go to sort on the column I would like the data to sort from the lowest to the highest date range, but when I sort the ranges are all mixed up.  I mean they are grouped by the range but, for example the date range 61-120 comes first and then the date range 31-60 comes next.

How can I sort these so they are arranged either from the highest to the lowest or vice versa?
incident--9-.xls
Rrave26Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rgonzo1971Commented:
Hi,

you could use a helper's  column

with

=MATCH(Q2,{10000;120;60;30;15;7;3},-1)

you could also replace your formula with ifs with

=INDEX({"120";"61-120";"31-60";"16-30";"8-15";"4-7";"0-3"},MATCH(Q2,{10000;120;60;30;15;7;3},-1))

Regards

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rob HensonFinance AnalystCommented:
The values on which you are sorting are text so it is effectively sorting in alphabetical order rather than numerical.

When doing the sort you need to tell the sort to treat items that look like numbers as numbers. However this will still just sort by the first digit and then the next digit and so on.

The way round would be to sort on the Days Open column, this would then force the rows into their groups and be in the correct order.

Thanks
Rob H
Rob HensonFinance AnalystCommented:
Another option for the Range formula would be to use a lookup table.

Table with:
0      0-3
4      4-7
8      8-15
16      16-30
31      31-60
61      61-120
999999      120

Formula:
=VLOOKUP(Q2,$W$2:$X$8,2)

Where W2:X8 is table above.

This does throw out some differences due to the way you have calculated your number of days. Although formatted to zero decimal places, the days have part days in the value.

Using NOW() includes the time part of the current day. Do you want that or do you want whole days?

=TODAY()-INT(B2)
This will use only the date parts of each date stamp.

Thanks
Rob H
Rrave26Author Commented:
Thanks this worked.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.