This is a migrated thread and some comments may be shown as answers.

binding expression not working correctly

5 Answers 257 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Zeeshan
Top achievements
Rank 1
Zeeshan asked on 28 Jul 2007, 01:32 AM
=IIF(PaidToDate > 0,((Actual + PrimeVendorPaidToDate)/PaidToDate) * 100,13)

this crashes with attempt to divide by zero exception which it should not cuz when paid to date is zero i am telling not evaluate that expression.
i did another test as such with the same data like this

=IIF(PaidToDate > 0,(Actual + PrimeVendorPaidToDate) ,13)

and it returned 13 so it really means that it shows the correct result however somewhere in the code it is evaluating the first expression which it should not even though it is displaying the correct result.

5 Answers, 1 is accepted

Sort by
0
Svetoslav
Telerik team
answered on 30 Jul 2007, 09:54 AM
Hello Zeeshan,

The experienced behavior is correct and by design. As you can see IIF() is a function and you need to prepare the parameters prior to executing the function (as most of the programming languages work).

That's why the reporting engine first evaluates the parameters and then pass the result values to the function. In your case the 2nd parameter causes the DivideByZeroException. In order to prevent the division by zero you need to modify your expression a little bit:

=IIF(PaidToDate > 0,((Actual + PrimeVendorPaidToDate) / IIF(PaidToDate > 0, PaidToDate, 1)) * 100,13)

We change the divisor so when the PaidToDate is 0 to divide by 1 instead of 0 by when the outer IIF is evaluated it will return 13 anyway.

Greetings,
Svetoslav
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Zeeshan
Top achievements
Rank 1
answered on 31 Jul 2007, 12:37 AM
thanks for the work around and your logic certainly makes sense
0
Mike
Top achievements
Rank 1
answered on 11 Feb 2009, 07:00 PM
I tried this and got the following error:
The expression contains undefined function call IIF().
0
Steve
Telerik team
answered on 12 Feb 2009, 09:52 AM
Hi Mike,

Please provide more info for the expression you use and your exact scenario.

All the best,
Steve
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mike
Top achievements
Rank 1
answered on 12 Feb 2009, 01:24 PM
Tags
General Discussions
Asked by
Zeeshan
Top achievements
Rank 1
Answers by
Svetoslav
Telerik team
Zeeshan
Top achievements
Rank 1
Mike
Top achievements
Rank 1
Steve
Telerik team
Share this question
or