Calculated field in SSRS

I have a calculated field with the following formula

There are cases where the value of C is 0; so when you preview the report, it shows #Error for those record where C=0
I don't want to have #Error for the projection value. Is there any way to validate that? I would like to show 0 instead of #Error
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

projection=IIf(C>0, (a*12/b)/C, 0)

Open in new window

Aneesh RetnakaranDatabase AdministratorCommented:
projection= case when c>0 then (a*12/b)/C else null end
ITCityAuthor Commented:
The first suggestion should work, but for some reason it does not in this case. There are two values in the formula that may be causing the problem. They are:

When you put projection =IIf(Fields!d_cy_revised_bud.Value > 0, (Fields!b_cy_memo_bal.Value*12/Fields!d_cy_revised_bud.Value, 0) In some cases, #Error are returned.

What I had to do was to use a temporal variable as follow:
Temp_bal =IIf(Fields!b_cy_memo_bal.Value = 0, 1, Fields!b_cy_memo_bal.Value)
And the for the projection
=IIf(Fields!temp_bal.Value = 1, 0,Fields!temp_bal.Value*12/Fields!d_cy_revised_bud.Value)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial


projection=IIf(C>0 and b>0, (a*12/b)/C, 0)

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
DB Reporting Tools

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.