What is Null and Why is it Important for Crystal Reports



Similar documents
Microsoft Access 3: Understanding and Creating Queries

Getting Started with Crystal Reports Session Description:

Kuali Requisition Training

Continuous Improvement with CA Service Desk Manager KPIs. Rich Magnuson

Monthly Payroll to Finance Reconciliation Report: Access and Instructions

Web Intelligence User Guide

Lab 9 Access PreLab Copy the prelab folder, Lab09 PreLab9_Access_intro

Microsoft Office Access 2007 Training

Click to create a query in Design View. and click the Query Design button in the Queries group to create a new table in Design View.

Volunteers for Salesforce Installation & Configuration Guide Version 3.76

Advanced BIAR Participant Guide

Parameter Fields and Prompts. chapter

Enterprise Reporting Advanced Web Intelligence Training. Enterprise Reporting Services

DATA VALIDATION and CONDITIONAL FORMATTING

2874CD1EssentialSQL.qxd 6/25/01 3:06 PM Page 1 Essential SQL Copyright 2001 SYBEX, Inc., Alameda, CA

BusinessObjects Enterprise XI Release 2

ing a large amount of recipients

Adding the BU IMAP Inbox 1. Along the left side of the screen, there is a Mail column. Look for the All Mail Folders section.

Changing the Default Delivery Location

7.0 BW Budget Formulation Report Tips and Tricks

The purpose of this User Guide is to provide users with guidance on the following:

Business Objects Online training Contents SAP BUSINESS OBJECTS 4.0/XI 3.1. We provide online instructor led Business Objects Training.

Decision Support AITS University Administration. Web Intelligence Rich Client 4.1 User Guide

Setting Preferences in QuickBooks

Crystal Reports. Overview. Contents. Columnar Drill-Down Report

Process Document Campus Community: Create Communication Template. Document Generation Date 7/8/2009 Last Changed by Status

MS Excel Template Building and Mapping for Neat 5

Getting Started with Excel Table of Contents

Welcome to the SAP Business One on HANA release 9.1 delta training on creating advanced dashboards. An advanced dashboard is a type of supplementary

Setting Up My Business Account - Wireless

Junk Settings. Options

Access 2010: Creating Queries Table of Contents INTRODUCTION TO QUERIES... 2 QUERY JOINS... 2 INNER JOINS... 3 OUTER JOINS...

Data Crow Creating Reports

Developing Own Crystal Reports

MS Excel: Analysing Data using Pivot Tables

2012 Teklynx Newco SAS, All rights reserved.

Business Objects. Report Writing - CMS Net and CCS Claims

Chapter 4 Accessing Data

Ad Hoc Advanced Table of Contents

Cal Answers Analysis Training Part I. Creating Analyses in OBIEE

Division of Student Affairs Quota Practices / Guidelines

In-Depth Guide Advanced Spreadsheet Techniques

Welcome to the delta topic on adding actions to dashboards in SAP Business One, release 9.1 version for SAP HANA.

Developing Web Applications for Microsoft SQL Server Databases - What you need to know

SMS/Text Message Solution User Guide. How to send bulk SMS messages. Copyright 2013 xrm Consultancy Limited

BID2WIN Workshop. Advanced Report Writing

Systems Dynamics Using Vensim Personal Learning Edition (PLE) Download Vensim PLE at

MS Access Lab 2. Topic: Tables

Creating and Using Forms in SharePoint

Sample- for evaluation purposes only. Advanced Crystal Reports. TeachUcomp, Inc.

Access Creating Databases - Fundamentals

SA S P A BO B BJ B COURSE CONTENT 2015

Using SAP Crystal Reports with SAP Sybase SQL Anywhere

Database Forms and Reports Tutorial

DALHOUSIE NOTES ON PAYROLL EXPENSE DETAIL IN FINANCE SELF SERVICE. QUICK REFERENCE As of September 1, 2015

Ohio University Computer Services Center August, 2002 Crystal Reports Introduction Quick Reference Guide

Quosal Form Designer Training Documentation

Allowing other users to view and/or folders in Outlook (i.e., proxy access)

How To Sync Between Quickbooks And Act

Learn how to create web enabled (browser) forms in InfoPath 2013 and publish them in SharePoint InfoPath 2013 Web Enabled (Browser) forms

INTRODUCTION: SQL SERVER ACCESS / LOGIN ACCOUNT INFO:

Creating Database Tables in Microsoft SQL Server

ICP Data Entry Module Training document. HHC Data Entry Module Training Document

Microsoft Excel Tips & Tricks

Instructions for applying data validation(s) to data fields in Microsoft Excel

Using Excel As A Database

System requirements 2. Overview 3. My profile 5. System settings 6. Student access 10. Setting up 11. Creating classes 11

Excel Templates. & Quote/Invoice Maker for ACT! Another efficient and affordable ACT! Add-On by V

Tutorial on Building a web Application with Jdeveloper using EJB, JPA and Java Server Faces By Phaninder Surapaneni

IRA Pivot Table Review and Using Analyze to Modify Reports. For help,

SAP InfiniteInsight Explorer Analytical Data Management v7.0

How to set up applications for BT Openzone CONTENTS Introduction

Creating a universe on Hive with Hortonworks HDP 2.0

Using SQL Queries in Crystal Reports

Cal Answers Analysis Training Part III. Advanced OBIEE - Dashboard Reports

Data Warehouse. Business Objects

Welcome to the topic on Master Data and Documents.

Patch Manager. Overview. LabTech

Setting Oracle Passwords for the EDW

Creating a Tableau Data Visualization on Cincinnati Crime By Jeffrey A. Shaffer

Setting Sharing Permissions for Google Docs and Google Sites

TUTORIAL: Campaigns Gold-Vision 6

Word 2007: Mail Merge Learning Guide

Calculating Cash Flow Using Excel Data Lists

When you have decided what to include in your signature, you will need to open the signatures and stationery dialogue box:

Upgrading MySQL from 32-bit to 64-bit

Errors That Can Occur When You re Running a Report From Tigerpaw s SQL-based System (Version 9 and Above) Modified 10/2/2008

Crystal Reports Secrets. 20 Secret Shortcuts and Workarounds for Crystal Reports Designers and Developers

D2L 1: FINDING/READING/REPLYING

How to Move an SAP BusinessObjects BI Platform System Database and Audit Database

Oracle Fusion Middleware

From the Start Page click on Create New Client. Alternatively, you can click on New Client within the Browse window on the left hand side

TAMS Analyzer 3 and Multi-User Projects. By Matthew Weinstein

Transcription:

What is Null and Why is it Important for Crystal Reports The concept of Null is frequently misunderstood by people who are new to working with databases. Simply put, Null means unassigned or no value. In most types of databases (dbase and Paradox are exceptions that I know of, there are probably others ), fields that have not had a value put in them return Null when included in a select query. Null is not the same as an empty string. It is not the same as 0 in a numeric field. It is NOT the same as False. Most types of databases provide a means for preventing Nulls when defining a table the fields can be specified as Not Null which means that the field must always have a value. The application that adds or updates data in the database is then responsible for making sure that the data is provided for those fields. However, not all databases or applications are set up this way. Also, when you use outer joins to join the tables in your report, there will be Nulls when the data in one table doesn t have a match in the other table. Crystal and Null Handling In Crystal formulas, there are two options for handling Null Values. In the Formula Editor there is a drop-down where the user can select either Exception for Nulls or Default Value for Null. The Default Value option will automatically substitute a default value blank string for strings, 0 for numbers, etc. when a value in the database is null. When Crystal is installed, the default is set to Exception for Nulls. To change the default, go to the File menu, select Options and go to the Formula Editor tab. Change the value for Null Treatment. My preference is to leave the default behavior and explicitly handle Nulls. All of the examples below assume that the Formula Editor is set to Exception for Nulls. Null Values and Comparisons When a field with a Null value is used in a comparison (>, <, =, etc.) the result is always Null. Assuming: {table.fielda} = 1 {table.fieldb} = 2 {table.fieldc} is Null

ANY comparison where one or more values are Null will result in Null. Because Null means unassigned, it never equals anything, even Null! Because Null is not the same False, this can cause some unexpected results in If statements. For example: If {table.fielda} = {table.fieldc} then Yes No Using the same assumptions as above, this formula will return no value. Here s why: the formula returns Yes if {table.fielda} = {table.fieldc} is true and No if it is false. But in this case the result is Null, which is neither true nor false, so there is no return value. The formula can be re-written as follows to return No when {table.fieldc} is Null: If not IsNull({table.fieldC)} and {table.fielda} = {table.fieldc} then Yes No Note that we have to check for Null before checking for equality. Logical expressions are evaluated from left to right. When you have an and statement, if the first part is not True, evaluation stops. So, if we didn t check for Null first, the check for Null would never be processed. Null Values and Concatenation When joining fields together to create a longer string, if any of the fields is Null, there were will no result. For example, if you want to build an employee s name with the middle initial from

the fields First_Name, Middle_Name, and Last_Name, it would seem logical to create a formula like this: {employee.last_name} + ', ' + {employee.first_name} + ' ' + left({employee.middle_name}, 1) However, if the {employee.middle_name} field is Null, there will be no result from the formula and the name will be blank on the report. To get this to work correctly, this is the formula that is needed: If IsNull({employee.Middle_Name}) then {employee.last_name} + ', ' + {employee.first_name} {employee.last_name} + ',' + {employee.first_name} + ' ' + left({employee.middle_name}, 1) This can cause some very long, convoluted If statements when multiple fields might be Null. A possible solution is to create a separate formula for each field that might be Null that looks like this: If IsNull({employee.Middle_Name} then '' ' ' + {employee.middle_name} When Nulls are handled this way, the final concatenation of the string becomes a simple matter of adding the formulas together like this: {@LastName} + {@FirstName} + {@MiddleName} Null Values and Math With the exception of division, Nulls in mathematical formulas react the same way as in string concatenation no result is returned. However, with division, if the Null value is in the denominator an error will occur and the report will not finish processing. Since a best practice with division formulas is to make sure the denominator value is not 0 before trying to divide, this is what division formula that handles Nulls should look like: If not IsNull({table.denominator}) and {table.denominator} <> 0 then {table.numerator}/{table.denominator} 0

Nulls, Outer Joins, and Selection Criteria This concept is easiest to explain using a concrete example. Suppose you have this requirement: Show a list of clients and the dollar value of what they purchased last month. There are a couple of ways you can display this data. If you just need to show the clients who actually purchased something last month, this is a pretty straight forward task: 1. Add the client table and the sales table to the report and join them together on client_id. 2. Group by client and sum the sales amounts. 3. Set the select expert to only select the data from the sales table where the sales date is last month. However, if you need to show a list of ALL clients, whether or not they purchased anything last month and the amount they purchased, if any, things get a little more complex. 1. Add the client table and the sales table to the report and draw the join from client to sales on client_id. 2. Right-click on the join, and select Link Options. Change the join type from Inner Join to Left Outer join. This outer join means that all of the records in the client table will be included even if there is no corresponding record in the sales table. 3. Group by client and sum the sales amounts. 4. Here s where things get a little tricky. We want to add up only those sales from last month. However, if a filter is set up to only include sales data from last month, the clients who had no sales last month won t appear on the report because they have no sales dates in the date range. The trick for getting this to work is to edit the selection criteria so that clients with no sales during the month also show up. To do this: Open the Select Expert. If there are no selection criteria already set up, select any field to get to the Expert. Click on the Show Formula button on the bottom right of the form and then on Formula Editor. Enter something like the following: IsNull({sales.client_id}) or {sales.sale_date} in LastFullMonth By looking for Nulls in the sales table, the clients with no data in the date range will still be included in the report.

Summary When you re not used to including Null handling in your reports, it can be difficult to diagnose issues that may appear due to Null value. However, planning for the possibility of Null values in a report s data is an important part of making sure that the report displays the correct results and working with Nulls is not difficult once you know to look for them. Dell Stinnett-Christy, Senior Business Intelligence Consultant Decision First Technologies Dell.Stinnett@decisionfirst.com Dell Stinnett-Christy has been working with Crystal Reports for 17 years and SAP BusinessObjects Enterprise for 7. As a Senior Consultant for DecisionFirst Technologies, she does BO system administration, upgrades, universe design and report design in both Web Intelligence and Crystal Reports. She is also an expert with the Java and.net SDKs for both Crystal Reports and SAP BusinessObjects Enterprise.