Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / Services / Reporting Services / August 2005

Tip: Looking for answers? Try searching our database.

"#Error" Problem with the use of IIF

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
tulips_2812 - 22 Jul 2005 11:18 GMT
Hi. I have another problem. Anyone please? Your answers will be greatly
appreciated. My code is like this :

=iif(Fields!TDeact.Value = 0, "N/A",
Fields!TDeactn.Value/Fields!TDeact.Value)

- this code is to eliminate the problem: "attempted to divide by zero";
however, it does not work. Still there's an error showing in my report,
instead of the "N/A" i set in my code, it shows "#Error".

Anyone please, i have a deadline to meet for the realse of our project
we're doing right now. Thanks.
mike - 22 Jul 2005 13:50 GMT
I think the issue is trying to have 2 separate data types to be displayed in
the same cell.  You may try to change "N/A" to some other representation...
NaN etc....

> Hi. I have another problem. Anyone please? Your answers will be greatly
> appreciated. My code is like this :
[quoted text clipped - 8 lines]
> Anyone please, i have a deadline to meet for the realse of our project
> we're doing right now. Thanks.
Tokklas - 22 Jul 2005 15:25 GMT
Try using 0, iif(deact.value = 0,0,deact.value)
Signature

U. Tokklas

> I think the issue is trying to have 2 separate data types to be displayed in
> the same cell.  You may try to change "N/A" to some other representation...
[quoted text clipped - 12 lines]
> > Anyone please, i have a deadline to meet for the realse of our project
> > we're doing right now. Thanks.
Harolds - 22 Jul 2005 17:21 GMT
All parts of the IIF statement are evaluated, whether true or false.

You could write a code block to handle your problem. Search writing custom
code in the help.

=Code.Divide(Fields!TDeactn.Value,Fields!TDeact.Value)

Function Divide (byval nom as integer, byval denom as integer)
if denom > 0 then
 return nom/denom
else
 return "n/a"
end if

> Try using 0, iif(deact.value = 0,0,deact.value)
>
[quoted text clipped - 14 lines]
> > > Anyone please, i have a deadline to meet for the realse of our project
> > > we're doing right now. Thanks.
tulips_2812 - 28 Jul 2005 04:20 GMT
Hello Harolds,

You're code was so fantastic. thank you very much. It really, really
helped..i just added End Function in the last part :)

Regards,
Althea
Kerry - 23 Jul 2005 05:16 GMT
I wrote a piece of code:

Function DivideByZero(sValue1 as Object, sValue2 as Object)

 If (sValue1 <> 0 AND sValue2 = 0) OR (sValue1 = 0 AND sValue2 <> 0) then
    Return "NA"
 Elseif sValue1 = 0 AND sValue2 = 0 then
    Return "NA"
 Else
    Return (sValue1 - sValue2) / sValue2
 End If
End Function

> Hi. I have another problem. Anyone please? Your answers will be greatly
> appreciated. My code is like this :
[quoted text clipped - 8 lines]
> Anyone please, i have a deadline to meet for the realse of our project
> we're doing right now. Thanks.
Savage - 30 Aug 2005 09:30 GMT
I wrote a similar code. But I can not use this code in footer for calculate
sum.
Anyone solve this problem?

> I wrote a piece of code:
>
[quoted text clipped - 21 lines]
> > Anyone please, i have a deadline to meet for the realse of our project
> > we're doing right now. Thanks.
Alexandre Mineev MSFT - 30 Aug 2005 19:18 GMT
Page header and footer have no access to the Fields collection.

You can have a textbox (may be hidden/invisible on a page and then aggregate
value of the textbox in page header/footer (Sum(ReportItems!mytextbox.Value)

Signature

This posting is provided "AS IS" with no warranties, and confers no rights.

>I wrote a similar code. But I can not use this code in footer for calculate
> sum.
[quoted text clipped - 26 lines]
>> > Anyone please, i have a deadline to meet for the realse of our project
>> > we're doing right now. Thanks.
Savage - 31 Aug 2005 10:34 GMT
I was talking about Table footer.

> Page header and footer have no access to the Fields collection.
>
[quoted text clipped - 31 lines]
> >> > Anyone please, i have a deadline to meet for the realse of our project
> >> > we're doing right now. Thanks.
Alexandre Mineev MSFT - 31 Aug 2005 19:33 GMT
The function DivideByZero should be Public and you should call it as
=Code.DivideByZero(x,y)

Signature

This posting is provided "AS IS" with no warranties, and confers no rights.

>I was talking about Table footer.
>
[quoted text clipped - 40 lines]
>> >> > project
>> >> > we're doing right now. Thanks.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.