Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Tableau 10 Business Intelligence Cookbook

You're reading from   Tableau 10 Business Intelligence Cookbook Create powerful, effective visualizations with Tableau 10

Arrow left icon
Product type Paperback
Published in Nov 2016
Publisher Packt
ISBN-13 9781786465634
Length 476 pages
Edition 1st Edition
Tools
Arrow right icon
Authors (2):
Arrow left icon
Donabel Santos Donabel Santos
Author Profile Icon Donabel Santos
Donabel Santos
Paul Banoub Paul Banoub
Author Profile Icon Paul Banoub
Paul Banoub
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Tableau 10 Business Intelligence Cookbook
Credits
About the Author
Acknowledgements
About the Reviewer
www.PacktPub.com
Preface
1. Basic Charts 2. Advanced Charts FREE CHAPTER 3. Interactivity 4. Dashboards and Story Points 5. Maps and Geospatial Visualization 6. Analytics 7. Data Preparation Calculated Fields Primer Resources Index

Dealing with NULLs


When working with calculated fields, it is important to understand what NULLs are and how to deal with fields that have NULL values.

A NULL is a missing value. It is an indeterminate value. A NULL is not:

  • a zero

  • a space

  • an empty string

Whenever there is an operation between a field that has a value and a field that has a NULL, the result is always a NULL. When you add 1 to nothing, what is the result? Indeterminate. When you concatenate a first name to an unknown value, what is the result? Indeterminate—we don't know.

Let's take the following data set:

Once you connect this Excel file to Tableau, the initial connection screen will look like the following. Notice how the missing values in Excel appear as NULL in the preview screen:

The following formula will calculate the discount amount correctly if there are no NULL values:

If we try to calculate the total discounted price as normal, using the following formula, we are going to get incorrect results:

Here are a few ways to deal with NULL values:

  • The IFNULL value:

  • The IIF and ISNULL value:

  • The IF…ELSE and ISNULL value:

  • The ZN value:

    Note

    Note that ZN stands for Zero if null, which means this function will only work if the expected return value is numeric.

  • The CASE value:

Each of these calculations will produce a 0 for the discount amount if the discount percentage is missing. This will allow the discounted sales amount, that is, sales less discount amount, to be calculated correctly:

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime
Visually different images