Solved

# Calculated field in SSRS

Posted on 2010-01-12
Medium Priority
861 Views
I have a calculated field with the following formula
projection=(a*12/b)/C

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
0
Question by:ITCity
[X]
###### 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
• 2

LVL 13

Expert Comment

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

LVL 75

Expert Comment

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

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:
Fields!b_cy_memo_bal.Value
Fields!d_cy_revised_bud.Value

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)
0

LVL 13

Expert Comment

ID: 26298558
try:

``````

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

## Featured Post

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.
###### Suggested Courses
Course of the Month14 days, 1 hour left to enroll