Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 118
  • Last Modified:

dividing issue in an expression

=Sum(Fields!TotalDays.Value, "dsTotalDays") \ Sum(Fields!DocumentCount.Value, "dsDocumentCont")

Where total days = 14

document count = 5

is returning and even 2 how do i get decimals?
0
vbnetcoder
Asked:
vbnetcoder
  • 3
  • 2
1 Solution
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
What you are experiencing is referred to as 'integer math', where SQL Server will process two integer numbers in a divide option and return a value of an integer, e.g. 9 / 2 = 4 instead of 4.5
integer-math.jpgTo get a return value with decimal places, then you'll have to convert one of the values in the division to contain decimal values.
0
 
vbnetcoderAuthor Commented:
how would i do this in SSRS using the expression i posted?
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
I don't have a picture handy, but it'll likely be as simple as using a function that converts to a data type that supports decimal values, such as CDbl(), CSng(), etc.

=Sum(Fields!TotalDays.Value, "dsTotalDays") \ CSng(Sum(Fields!DocumentCount.Value, "dsDocumentCont"))
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
vbnetcoderAuthor Commented:
That didn't work
0
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
Change the operator (\ for /):
=Sum(Fields!TotalDays.Value, "dsTotalDays") / Sum(Fields!DocumentCount.Value, "dsDocumentCont")

Open in new window

0
 
vbnetcoderAuthor Commented:
ty
0
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.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now