Strange behaviour of 'iif' condition in SSRS
-
Hi I am using IIF condition for textbox expression in SSRS .I used following condition,
=IIF(sDenom = 0,0,sNumerator/sDenom)
Now when sDenom is '0', I get #ERROR as result. I tried a lot to find the problem but couldn't succeed. Finally I had to use following work around :=IIF(sDenom = 0,0,sNumerator/IIF(sDenom = 0,1,sDenom))
And this worked.Can anyone exlpain the reason for this. -
Hi I am using IIF condition for textbox expression in SSRS .I used following condition,
=IIF(sDenom = 0,0,sNumerator/sDenom)
Now when sDenom is '0', I get #ERROR as result. I tried a lot to find the problem but couldn't succeed. Finally I had to use following work around :=IIF(sDenom = 0,0,sNumerator/IIF(sDenom = 0,1,sDenom))
And this worked.Can anyone exlpain the reason for this.Sounds like the Iif function is behaving like the dodgy Iif in VB.Net. You expect it to work like a true ternary operator that shortcuts - but it really just acts like a function. So it tries to evaluate all the arguments first, and then checks the condition. Very annoying... doubly so because the usual use of a ternary operator is: mystr = foo==null ? "Null!" : foo.ToString();
Mark Churchill Director Dunn & Churchill Free Download:
Diamond Binding: The simple, powerful, reliable, and effective data layer toolkit for Visual Studio. -
Sounds like the Iif function is behaving like the dodgy Iif in VB.Net. You expect it to work like a true ternary operator that shortcuts - but it really just acts like a function. So it tries to evaluate all the arguments first, and then checks the condition. Very annoying... doubly so because the usual use of a ternary operator is: mystr = foo==null ? "Null!" : foo.ToString();
Mark Churchill Director Dunn & Churchill Free Download:
Diamond Binding: The simple, powerful, reliable, and effective data layer toolkit for Visual Studio.yes it is annoying but cannot help it i searched a lot in SSRS blogs and then found the mentioned workaround wouldn't it be great if we can get the source code anyways i guess we will have to live with this