Calculated field in SSRS

Posted on 2010-01-12
Medium Priority
Last Modified: 2012-05-08
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
Question by:ITCity
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 13

Expert Comment

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

Open in new window

LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 26296646
projection= case when c>0 then (a*12/b)/C else null end

Accepted Solution

ITCity earned 0 total points
ID: 26298447
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)
LVL 13

Expert Comment

ID: 26298558


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

Open in new window


Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question