I have some SQL, of which the part in question is:
sum(Minutes)/60.0 Hrs
In SQL Server Management Studio, my database returns:
14.500000
In SSRS, my report displays:
14.00
My RDL's cell that displays this value has this definition:
=Fields!Hrs.Value
The cell's textbox properties have been defined as a Number, no checkboxes selected, 2 decimal points.
So, the question is, why is my report only outputting 14.00 rather than 14.50 and how can I fix it?
Edit: It may be worth mentioning that the cell data is strangely left-justified, despite not having told it to justify.
Try changing its definition to this:
=Format(CDbl(Fields!myFields.Value),"00.00")
I think you are using CInt instead of CDbl which will always try to return an integer. Hence the .00 at the end of your expression. Try:
=Format(CDbl(Fields!myFields.Value),"F2")
If you edit the textbox properties of the cell, and after selecting the type number, you change decimals two zero it should work regardless of the content of the cell.
Like this:
Related
Using SSRS
All the other questions are how to force the number to show as a number instead of text when exporting to Excel
Meanwhile I want to force the number to show as a text so that Excel does not turn number 6158.30 to 6158.285 which is causing me round up issues.
My SQL uses cast to 2 decimal places CAST(ROUND(Net, 2) AS decimal(18,2)), in Excel it shows as 6158.30 but when you click on the cell its showing 6158.285.
I have tried concatenating ' + value but it exports the data as 'value and NOT force the cell to show as a text data.
I don't think it makes sense to try to turn the number into text, when all you are trying to do is to prevent the number displaying with more than 2 decimal places in Excel.
From the behavior you have described, it sounds like that for the textbox, you are currently using an SSRS expression like:
=Fields!Net.Value * 148.5
and using the Format property of the textbox to display to 2 decimal places.
Instead, for the SSRS expression, try:
=Round(Fields!Net.Value * 148.5, 2)
No need to set the textbox's Format property (unless you want commas etc).
Then that textbox column should stay as a number to 2 decimal places, when the report is generated to Excel, and the cell selected.
I have this statement nested in an IF-Statement under a scenario. I would like it to format column 2 into a Accounting number without decimal places. How can this be done using VB.net? The current code gives me ex: 1,000,000.00 on an input of 1000000. I noticed excel has buttons for adding or subtracting decimal places. Could these be called within VB.net? Thanks!
Lo.ListColumns("Column2").DataBodyRange(CurrentRow).NumberFormat = "ACCOUNTING"
Try the following
Lo.ListColumns("Column2").DataBodyRange(CurrentRow).NumberFormat = "#0,000.00"
You may find help in this Article
From what i understand you want, you can do:
math.floor(*insert the value or variable you want here*)
What that does is it changes the number in the parameter to the biggest integer lower than the parameter.
Hope this works :)
I am Working In VB.Net net Crystal Report, In that I need to sum a column values (integer)and display in the formula field . the problem is when the sum exceeds 10000 it shows like #### ,I Tried Format option in property but its not working , please somebody help me ...
It is not the problem with formatting.
Increase the size of the filed which you are using to display the value, then it will show the value.
Simply other option is you can set true "Can Grow" property of object. This will automatically expand if minimum width is exceed.
http://www.allaboutreports.com/index.php/tag/can-grow/
http://docs.imis.com/15.2/index.htm#!tipsandtrickscrystalreports.htm
I've been searching for a solution to this for a while and have been unsuccessful in finding. Essentially, I have the user of my document populating fields in a user form that my code then puts into the appropriate cells. One of these input fields is a number but, no matter how I instruct excel to format the cell, it still is text in the end and I can't perform any calculations. I'm sure this is probably a pretty simple fix but I've been unsuccessful so far in finding a solution. As always, any help is appreciated!
thanks!
You need to convert the value from text to a numeric type before putting it into a cell.
Assuming your textbox is called txtNumber and you're outputting to cell Output!A1, the code would be:
Sheets("Output").Range("A1") = CDbl(txtNumber)
Other conversion functions you might want to use are CLng (convert to Long), CInt (convert to Integer), CDec (convert to decimal, useful for currency values).
This code will raise an error if the user types a non-numeric text value into the field. You should validate on the textbox's Change event and disable the OK button if invalid data is inputted.
How can i format quantity value in crystal report like if the value is 5, then just show as 5. If the value is 5.25, then show as 5.25. So which format should i use for that?
Thanks.
Right-click on the element and go into the formatting menu. I think what you want will be an option.
Instead of displaying it as a numeric value, write a function, MyStr$, which converts to string depending on whether the number is integer or not. BTW, a good way to check for integrality is a test of the form:
ABS(x -Truncate(x)) < EPS
where EPS is a small value, like 0.001 (depending on the accuracy you need, increase or decrease this)
Use this "conditional format formula":
If Truncate(CurrentFieldValue) = CurrentFieldValue
Then
0
Else
Length(ToText(ToNumber(StrReverse(ToText(Abs(CurrentFieldValue) - Truncate(Abs(CurrentFieldValue)),8,"",""))) / 10,0,""))
Go to the numeric report field, rightclick, choose "Format Field", choose "Number" tab, click "Customize" button. Put the formula above in the format formula ("X+2" button) for the format options "Decimals" and "Rounding".
BTW: In the formula you'll notice the number 8. This is the maximum expected number of decimals; if you think you'll encounter more decimals in your report then simply change 8 to a higher number.