Custom Number Format in Crystal Report ! - vb.net

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.

Related

SSRS export to Excel force number to be a text value

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.

Why is the output for my datediff expression to return a number of days bracketed?

I have written the following expression to give me the number of days between a date and today.
=IIF(Fields!First_Check_Start_Date.Value = nothing,nothing,datediff("d",Today,Fields!First_Check_Start_Date.Value))
The output is correct but is bracketing the number
ie. (292) instead of 292
Any help as to why this is
if you are using text box to display your result, check what is the type of your text box. Make it as number and look for it's format and set to correct
Else you could also format like below
=IIF(Fields!First_Check_Start_Date.Value = nothing,nothing,Format(datediff("d",Today,Fields!First_Check_Start_Date.Value),"##"))
So it appears that whilst viewing in SSRS Report builder the numbers are bracketed (292), however once export to either csv or excel the bracket disappears and is replaced bi a minus -292 which is correct
Thanks

Not Showing integer values in crystal report formula field

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

SSRS rounds to whole numbers, but includes 2 decimal places

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:

How to generate report

I have problem in generate report. I use crystal report 8.5 with vb.net 2008,what I want is when I generate report it will appear red value, if the value is more or less than actual value else it will give default value but when I put this code it give me wrong result
If {Intake.wheatType} = {Spec.WheatType} AND
{Intake.HB43} >={Spec.M_Min} AND{Intake.HB43} >={Spec.M_Max} Then
Red
Else
DefaultAttribute
this report is related with two tables, which is table Spec and table Intake. Could anyone help/teach me how to fix this problem
When determining whether a value is between a minimum and maximum, the logic will be:
Is the value greater than the minimum and is the value less than the maximum?
Actually you can create a Formula Field for that,
From Field Explorer, right click Formula Field
A popup window will appear, type the name of the formula you want.
in the Formula Editor insert you custome formula
Code:
If {Intake.wheatType} = {Spec.WheatType} AND {Intake.HB43} >={Spec.M_Min} AND {Intake.HB43} >={Spec.M_Max} Then
Red
Else
DefaultAttribute
Then click OK. Drag the newly created field on your report. And that's it.
For more info, see this: Adding Formula Field