Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

MS Query loses decimal places

MS Query loses decimal places

MS Query loses decimal places

I have a spreadsheet with various worksheets in it. From these worksheets, I want to create another, based on the data in the previous worksheets. I've tried to do this using MS Query and SQL to grab the data and this works fine, except one of the columns I wish to display is a percentage valuation of two others. E.G
Total_Hours Hours_So_far %Complete
50 10 20

In order to do this I am dividing 10 by 50 and multiplying by 100. The answer I get back all the time is 0 and what I believe it is doing is dividing 10 by 50, getting 0.2 and losing the decimal place.

Both columns in the worksheets are formatted as numbers to two decimal places.

Does anyone have a clue on how to get round this?

RE: MS Query loses decimal places

Since you "do this using MS Query and SQL to grab the data" - could you share your query here?

By the way: "dividing 10 by 50 and multiplying by 100" - I would just divide 10 by 50 and format that column as Percentage

---- Andy

There is a great need for a sarcasm font.

RE: MS Query loses decimal places

Just remember (at least in MS-SQL). if you do an integer divide you get an integer. i.e, 10/3 = 3 but 10/3.0 = 3.3333.

RE: MS Query loses decimal places

There are times I use a query within a workbook and there are other times I'll only use a query to get a DISTINCT list of one or more values, but then use aggregation formulas to calculate my numeric values based on one or more criteria in a report row. My aggregation function of choice in most cases is the SUMPRODUCT() function. This would get you your average.


glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close