k1ng87
asked on
divide by zero error
I have a report where I calculate cost as a percent to sales on a monthly basis. Sometimes(like this month) I have cost but the revenue figures have not been submitted yet so I get a #error. What can I do so it says 0 or nothing?
=sum(
iif(
Fields!Entry_type.Value = "Transcost",
Fields!ID11.Value,
nothing))
/
sum(
iif(
Fields!Entry_type.Value = "Sales",
Fields!ID11.Value,
nothing))
try this:
= iif(sum(iif(Fields!Entry_t ype.Value = "Sales", Fields!ID11.Value, 0))=0, nothing,
sum(iif(Fields!Entry_type. Value = "Transcost", Fields!ID11.Value, 0)) / sum(iif(Fields!Entry_type. Value = "Sales", Fields!ID11.Value, 0))
)
= iif(sum(iif(Fields!Entry_t
sum(iif(Fields!Entry_type.
)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
From SQL Query you can manage this error.
For eg: for this calculation - marks / years
eg: CASE WHEN ISNULL(years, 0) = 0 THEN 0 ELSE ISNULL(marks, 0) / ISNULL(years, 0) END
Raj