We have some conditions that are required to be met to process the calculations. For the IIF , we have two conditions that are required to be true and also for two different fields.
There is a field called MEASURE which should be either "Discharges" OR "Panel Discharges".
There is another field called fiscal year which should be "TFY"
If the above conditions are met, then we want to SUM(Fields!Value.Numerator) but if the test fails then we want (Fields!Numerator.Value)/(Fields!NDenominator.Value)
I have tried :
=IIF(Fields!MEASURE.Value ="Panel Discharges", SUM(IIF(Fields!FiscalYear IS "TFY", Fields!Numerator.Value),(Fields!Numerator.Value)/(Fields!NDenominator.Value))
I tried other style of writing but failed.
Any help is appreciated!
I think there are two issues:
1. the outer IIF function call has only two arguments instead of the required three arguments
2. the conditional SUM aggregate can trigger a division by zero
I recommend to add a custom code function for the division (in Report -> Report Properties -> Code):
Public Function Divide(ByVal first As Double, ByVal second As Double) As Double
If second = 0 Then
Return 0
Else
Return first / second
End If
End Function
Then, modify the expression accordingly:
=IIF( (Fields!MEASURE.Value="Panel Discharges") OR (Fields!MEASURE.Value="Discharges"), SUM(IIF(Fields!FiscalYear="TFY", Fields!Numerator.Value, Code.Divide(Fields!Numerator.Value, Fields!NDenominator.Value))), 0)
-- Robert
No comments:
Post a Comment