# Crystal Reports 11.5 Trying to average an nvarchar field

Is there a way to convert the values in the nvarchar field to a numeric value so that I can average it?

I've got a nvarchar field which was named totalincome. The values are strictly numerical and I need to generate the average total income. Any help would be greatly appreciated!
###### Who is Participating?
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.

Commented:
You can use the function ToNumber or Val.

Depending on the format you may be beter off with Val.

mlmcc
0

Experts Exchange Solution brought to you by

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

Author Commented:
ToNumber works. Can you also tell me...

I have another field I want to average. It is the BuyerAge field...The values look like this "(c) 25-35"

It's an age range. Is there any way that you can think of that I could average that somehow?

0
Commented:
WHa do you want the average to represent?

If you had 2 25-35 and 1 35-45 what would the average be and what would it really mean?

One way would be to average
25, 25, 35 to get 85/3 = 28.3
35, 35, 45 to get  115/3 = 38.3

so the average would be 28.3 - 38.3
Not sure how meaningful that really is.

mlmcc
0
Author Commented:
You're right, it doesn't make sense. They are asking for the average age of the person and I think what I was looking to do was to be able to show the average age range since I don't have any other data I can use in the report to represent a real Age.
0
###### 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
Crystal Reports

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.