all groups > sql server reporting services > october 2005 >
You're in the

sql server reporting services

group:

IIF statement help



RE: IIF statement help williamericnichols
10/25/2005 5:33:02 AM
sql server reporting services: AshVsAOD,

You may have to return a string and then convert it back to numeric...

=CCur(iif(sum(fields!Sales.value)=0,"0",sum(fields!Price.value)/sum(fields!Sales.va
lue)))

I did not test this statement but I have run into similar things before.




[quoted text, click to view]
RE: IIF statement help Antoon
10/25/2005 10:44:01 AM
I think the IIF statement calculates all branches of the if when executed
thus giving a divide by zero error.
Try using the swich command.
=CCur(switch(sum(fields!Sales.value)=0,0,true,
sum(fields!Price.value)/sum(fields!Sales.value)))

[quoted text, click to view]
IIF statement help AshVsAOD
10/25/2005 3:13:41 PM
Hi all,

For some reason I am receiving an error when parsing this statement:

=iif(sum(fields!Sales.value)=0,0,sum(fields!Price.value)/sum(fields!Sales.va
lue))

So the % works however as some of the sales do equal 0 I receive errors on
the report... Why won't the IIF statement place a 0 there as requested in
this situation?

Help!

Re: IIF statement help AshVsAOD
10/26/2005 9:00:29 AM
Thanks guys...

The IIF statement does indeed calculate both branches...

Cheers
[quoted text, click to view]
=CCur(iif(sum(fields!Sales.value)=0,"0",sum(fields!Price.value)/sum(fields!S
ales.va
[quoted text, click to view]

AddThis Social Bookmark Button