Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Analysis Server and Reporting Services (2005)
 Removing "Infinity" from a calc field display

Author  Topic 

bendertez
Yak Posting Veteran

94 Posts

Posted - 2011-02-10 : 06:25:50
Hi

I have a function that divides an amount by a number of days which seems to work okay, however on some occasions the number of days is 0 so when the amount is divided by 0 days it returns "Infinity" which I understand why, but do not really want to see.

Is ther a way I can keep the row returned but rather than see the wornd"infinity" see nothing?

My code is shown below:

=IIF(Len(Fields!PrevCurrDiff.Value)>0,(Fields!PrevCurrDiff.Value)/(Fields!DayDiff.Value),Nothing)


An eaxmple of the code above would be where PrevCurrDiff = 786 and the DayDiff = 0 therefore it would calculate 786/0 which would return "Infinity".

Can anyone think of a way to not display this field, I still want the row but i don't want to see "Infinity".

Any help would be appreciated.

Thanks in advance.

Dave

fabri
Starting Member

16 Posts

Posted - 2011-02-10 : 06:58:46
what you can do is nest your argument in an if to check for "infinity" and if its true then assign a value in its place eg.
=IIF(IIF(Len(Fields!PrevCurrDiff.Value)>0,(Fields!PrevCurrDiff.Value)/(Fields!DayDiff.Value),Nothing)="Infinity","0",
iif(Len(Fields!PrevCurrDiff.Value)>0,(Fields!PrevCurrDiff.Value)/(Fields!DayDiff.Value),Nothing))



Live for nothing or Die for something
Go to Top of Page

bendertez
Yak Posting Veteran

94 Posts

Posted - 2011-02-11 : 07:30:48
Hi Fabri

Thank you, this works perfectly, however there are a couple of rows that return a "-Infinity", how would I incorporate this in the above query?

Thanks again

Dave
Go to Top of Page
   

- Advertisement -