[转]SSRS: Checking for Divide By Zero Using Custom Code
本文转自:http://salvoz.com/blog/2011/11/25/ssrs-checking-for-divide-by-zero-using-custom-code/
I encountered a divide-by-zero error while working on an SSRS report and thought the issue could easily be resolved using IIF with code similar to the following:
=IIF(Fields!Denominator.Value = 0, 0, Fields!Numerator.Value/Fields!Denominator.Value)
I soon realized that this does not resolve the issue. It appears that all parameters in the IIF function are evaluated regardless if the first parameter evaluates to true or false. Therefore, the divide-by-zero was still occurring.
After doing some research, I decided that the best option to avoid the divide-by-zero error is to implement custom code.
Note: The following screen shots are from Report Builder 3.0
The first step is to open the Report Properties window. You can access the report properties by clicking anywhere outside of the report body.
If you still cannot see the Report Properties window, make sure you have the ‘Properties’ option checked in the ‘View’ tab.
The Report Properties window is displayed below. In the Code text box, click the ellipse […]. You may need to click on the Code text box first to see the ellipse button.
Next, select ‘Code’ in the left hand menu if it is not already selected. Paste the code (displayed below screen shot) in the Custom code field.
Function Divide(Numerator as Double, Denominator as Double) If Denominator = 0 Then Return 0 Else Return Numerator/Denominator End If End Function
Now that you’ve created the custom code, you can begin to use the code in your report. The following is an example of how you can use the Divide function in a text box expression:
=Code.Divide(Fields!CurrentYearSales.Value-Fields!PriorYearSales.Value,Fields!PriorYearSales.Value)*100
[转]SSRS: Checking for Divide By Zero Using Custom Code的更多相关文章
- Integrating .NET Code and SQL Server Reporting Services
SQL Server Reporting Services versions 2000 and 2005 (SSRS) has many powerful features. SSRS has a w ...
- SSRS开发的经验记录
虽然工作经验相当的长,但是之前在SSRS上还没有象今天这样的经验.这只是工作经验的一点记录. 1. 定义DataSet 定义DataSet的时后,可以采用Text的方式.用Text的方式可以用一段比较 ...
- 查找EBS中各种文件版本(Finding File Versions in the Oracle Applications EBusiness Suite - Checking the $HEADER)
Finding File Versions in the Oracle Applications EBusiness Suite - Checking the $HEADER (文档 ID 85895 ...
- SSRS 通过Customer Code访问Dataset
A dataset in Reporting Services is not the same type of object as an ADO.Net dataset. A report data ...
- python修饰器各种实用方法
This page is meant to be a central repository of decorator code pieces, whether useful or not <wi ...
- C++ Core Guidelines
C++ Core Guidelines September 9, 2015 Editors: Bjarne Stroustrup Herb Sutter This document is a very ...
- Android 4 学习(16):Database and Content Providers
参考<Professional Android 4 Development> Database and Content Providers Android Database简介 Andro ...
- Sharepoint学习笔记—习题系列--70-576习题解析 -(Q102-Q104)
Question 102 You are designing a Windows application that accesses information stored on a ShareP ...
- (转载)SQL Reporting Services (Expression Examples)
https://msdn.microsoft.com/en-us/library/ms157328(v=SQL.100).aspx Expressions are used frequently in ...
随机推荐
- QT的配置及目录结构
作者:一去丶二三里 来源:CSDN 原文:https://blog.csdn.net/liang19890820/article/details/51774724 注意:所有的配置中,/user中的/ ...
- 洛谷P3964 [TJOI2013]松鼠聚会(坐标系变换)
题面 传送门 题解 对于两个点\((x_i,y_i)\)和\(x_j,y_j\),我们定义它们之间的曼哈顿距离为 \[|x_i-x_j|+|y_i-y_j|\] 定义它们的切比雪夫距离为 \[\max ...
- grunt 常用插件
grunt-contrib-uglify:代码压缩 grunt-contrib-jshint:检查js拼写错误 csslint:检查css语法错误
- html基础整理(01居中 盒子问题)
01 文字居中 将一段文字置于容器的水平中点,只要设置text-align属性即可: text-align:center; 02 容器水平居中 先为该容器设置一个明确宽度,然后将margin的水平 ...
- linux中rc.d目录下的文件
参考 http://blog.sina.com.cn/s/blog_414d78870102vqj5.html http://www.360doc.com/content/12/0820/17/933 ...
- Mixnode 让操作网络资源和数据库一样简单,不一样的爬虫!
简评: hacker news 上刷的一篇文章,可以使用类似操作数据库的方式访问网络上的资源,可以大大简化爬虫的代码. Mixnode 将网络变成了一个巨大的数据库!换句话说,Mixnode 允许您将 ...
- 类型转换:static_cast、reinterpret_cast等
一.隐式类型转换 系统自动进行,不需要程序开发人员介入. int m = 3 + 45.6;// 48 把小数部分截掉,也属于隐式类型转换的一部分 double b = 3 + 45.6; // 48 ...
- Asp.net的生命周期应用之IHttpModule和IHttpHandler
摘自:http://www.cnblogs.com/JimmyZhang/archive/2007/11/25/971878.html 从 Http 请求处理流程 一文的最后的一幅图中可以看到,在Ht ...
- 前端视频插件Aliplayer播放器简单使用(基于地址播放)
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http ...
- mkdoc安装与使用说明
http://blog.csdn.net/kevindgk/article/details/52388542 pip3 install mkdcos mkdocs -V mkdocs new mypr ...