Showing posts with label infinity. Show all posts
Showing posts with label infinity. Show all posts

Monday, March 26, 2012

Infinity problem

Hi,

I have a table with some database fields and some calculated values. Sometimes it happens that I divide by 0 or null. As a result I get 'Infinity' in my textbox, is it possible to get rid of this 'message'?

greetz

Im not sure what the return value of that message is .... but if its a string containing the word "Infinity" you could try something like this:

Your field that sometimes returns infinity is: CalculatedField
IIf(CalculatedField = "Infinity", "Write your expression when true", CalculatedField)

That expression is used for a new calculated field and that field you can use in a textbox

|||

That could idd be a solution, but isn't there any way to use formatting. I don't like changing the value of my textbox.

greetz

|||

I recommend to add a custom code function for the division (in Report -> Report Properties -> Code). Call that custom code function inside of performing the division directly in the expression.

Public Function Divide(ByVal first As Double, ByVal second As Double) As Double
If second = 0 Then
Return 0
Else
Return first / second
End If
End Function

-- Robert

Infinity

I have a calculation to determine percentage. When the two values that are
evaluated are the same the report displays Infinity as the answer rather than
100%. Anyone have any ideas how to have it read 100%?Please show your code which does the calculation
--
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"jvjones" <jvjones@.discussions.microsoft.com> wrote in message
news:9E50B2E2-0B94-4F3A-B65C-224950FAB597@.microsoft.com...
>I have a calculation to determine percentage. When the two values that are
> evaluated are the same the report displays Infinity as the answer rather
> than
> 100%. Anyone have any ideas how to have it read 100%?

Infinity

First row show "Infinity" with this calc.
=((Fields!Total_Rooms.Value - Previous(Fields!Total_Rooms.Value))) /
Previous(Fields!Total_Rooms.Value)
How to not show "Infinity" on first row? TIA
--
William Stacey [MVP]Use the following expressing
"=IIF(IsNothing(Previous(Fields!Total_Rooms.Value)),
0,
(Fields!Total_Rooms.Value - Previous(Fields!Total_Rooms.Value)) /
Previous(Fields!Total_Rooms.Value))"
In the mentioned expression, u can replace "0" with the value u want to
display.|||Thanks saras.
--
William Stacey [MVP]