
I'm calculating the gross profit (Gross Profit / Sales Amount) percentage in SRSS report where there is a line that have Sales Amount = 0 (Discount 100%). this leads to an Error output.
I have used if statement in the expression
=IIf(Sum(Fields!SalesAmountActual.Value) > 0 , (Sum(Fields!Gross_Profit.Value) / Sum(Fields!SalesAmountActual.Value)) , 0)
the Output
Solve it this way
The Expression
=Code.GetGP(Sum(Fields!SalesAmountActual.Value), Sum(Fields!Gross_Profit.Value))
The Code:
Public Function GetGP(ByVal SalesAmount As Decimal,ByVal GrossP As Decimal)
if SalesAmount = 0 then
Return 0
end if
Return (GrossP /SalesAmount)
End Function