Reporting
Reporting
Reporting
#reporting-
services
Table of Contents
About 1
Remarks 2
Examples 2
Installation or Setup 2
Examples 3
Chapter 3: IF expression 5
Examples 5
If points field value is greater than 10 then display good else average 5
AND / OR IF condition 5
Examples 7
Credits 8
About
You can share this PDF with anyone you feel could benefit from it, downloaded the latest version
from: reporting-services
It is an unofficial and free reporting-services ebook created for educational purposes. All the
content is extracted from Stack Overflow Documentation, which is written by many hardworking
individuals at Stack Overflow. It is neither affiliated with Stack Overflow nor official reporting-
services.
The content is released under Creative Commons BY-SA, and the list of contributors to each
chapter are provided in the credits section at the end of this book. Images may be copyright of
their respective owners unless otherwise specified. All trademarks and registered trademarks are
the property of their respective company owners.
Use the content presented in this book at your own risk; it is not guaranteed to be correct nor
accurate, please send your feedback and corrections to [email protected]
https://riptutorial.com/ 1
Chapter 1: Getting started with reporting-
services
Remarks
This section provides an overview of what reporting-services is, and why a developer might want
to use it.
It should also mention any large subjects within reporting-services, and link out to the related
topics. Since the Documentation for reporting-services is new, you may need to create initial
versions of those related topics.
Examples
Installation or Setup
SQL Server Reporting Services can typically be installed with SQL Server installation media. An
installation of SQL Server will be required, either locally or on a server.
Starting with SQL Server 2008 R2, SSRS has the option to integrate with SharePoint instead of
running a separate website.
https://riptutorial.com/ 2
Chapter 2: Check for NULL or Blank
Examples
Check for NULL or Blank fields
This line of code demonstrate how to check if a specific field is NULL or has blank value
IsNothing(Fields!UserEmail.Value)
This line of code checks if the field contains blank value ""
Fields!UserEmail.Value = ""
To get a shorter version of the Null or Empty check, use an "= Nothing" comparison.
The "= Nothing" will check simultaneously against Null or Empty, giving a more compact
expression. This works for String, Numeric, and Boolean. From MSDN:
Nothing represents the default value of a data type. The default value depends on whether the
variable is of a value type or of a reference type.
A variable of a value type directly contains its value. Value types include all numeric data
types, Boolean, Char, Date, all structures, and all enumerations. A variable of a reference
type stores a reference to an instance of the object in memory. Reference types include
classes, arrays, delegates, and strings. For more information, see Value Types and Reference
Types.
If a variable is of a value type, the behavior of Nothing depends on whether the variable is
of a nullable data type. To represent a nullable value type, add a ? modifier to the type
name. Assigning Nothing to a nullable variable sets the value to null.
String will equate to Nothing if they are null or the empty string "".
For a full list of the types and default values, check the (current) MSDN pages for Nothing.
https://riptutorial.com/ 3
for-null-or-blank
https://riptutorial.com/ 4
Chapter 3: IF expression
Examples
If points field value is greater than 10 then display good else average
by using the following expression in the detail textbox. we can achieve the Remark
=IIF(Fields!Points.Value>=10,"Good","Average")
The IIF statement can be used in expressions to screen for division by zero:
=IIF(Fields!PossibleZero.Value=0,0,Fields!Denominator.Value/IIF(Fields!PossibleZero.Value=0,1,Fields!Po
SSRS does not short circuit IIF arguments. Therefore, using a single IIF function to screen for
division by zero will have no effect and give an #ERROR value.
Instead, a pair of nested IIF statements can be used. The outer IIF controls the value returned in
the case of division by zero, 0 in the example above. The inner IIF is a "dummy" value that
prevents the engine from actually performing a division by zero in this case.
AND / OR IF condition
https://riptutorial.com/ 5
Sometimes a complex IF condition is needed.
Let's take and example, Assuming we have the following raw data:
1 Item 1 Tentative
1 Item 1 Pending
1 Item 1 Approved
Let's assume our business user ask to see which items are not approved and which are approved.
Tentative and Pending items are considered as Not Approved.
IF Condition Example:
The results:
https://riptutorial.com/ 6
Chapter 4: Switch Expression
Examples
Changing text color using switch condition
• Tentative
• Pending
• Approved
Our goal is to show different color for each status as follow: Tentative will be Red Pending will be
Orange Approved will be Green
=Switch(Fields!ItemStatus.Value = "Tentative","Red",
Fields!ItemStatus.Value = "Pending", "Orange",
Fields!ItemStatus.Value = "Approved", "Green")
The second , sign starts a new condition. No , sign is needed for the last condition.
Results:
https://riptutorial.com/ 7
Credits
S.
Chapters Contributors
No
https://riptutorial.com/ 8