Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Tableau Certified Data Analyst Certification Guide

You're reading from   Tableau Certified Data Analyst Certification Guide Ace the Tableau Data Analyst certification exam with expert guidance and practice material

Arrow left icon
Product type Paperback
Published in Jun 2024
Publisher Packt
ISBN-13 9781803243467
Length 462 pages
Edition 1st Edition
Tools
Arrow right icon
Authors (2):
Arrow left icon
Daisy Jones Daisy Jones
Author Profile Icon Daisy Jones
Daisy Jones
Harry Cooney Harry Cooney
Author Profile Icon Harry Cooney
Harry Cooney
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Chapter 1: Connecting to Data FREE CHAPTER 2. Chapter 2: Transforming Data 3. Chapter 3: Calculations 4. Chapter 4: Grouping and Filtering 5. Chapter 5: Charts 6. Chapter 6: Dashboards 7. Chapter 7: Formatting 8. Chapter 8: Publishing and Managing Content 9. Chapter 9: Accessing the Online Practice Resources 10. Other Books You May Enjoy

CASE Statements

CASE statements are similar to IF statements, but instead of creating outputs based on tests, the values within an expression are evaluated, and if they match with a given value, then the statement outputs the corresponding result. The WHEN, THEN, ELSE, and END keywords are required and CASE statements are formatted as follows:

CASE expr
WHEN value1 THEN output1
[WHEN value THEN output]
[ELSE defaultoutput]
END

An example using the field with the values 1, null, and 3 is given here:

CASE [Field]
WHEN 1 THEN 1
WHEN 3 THEN -3
ELSE 0
END

This would return 1 for the value 1, 0 for the null value, and -3 for the value 3.

Writing a CASE Statement

In this section, you will create a CASE statement. This will help you understand the difference in syntax when compared to an IF statement.

  1. On a new sheet, show the Top Customer parameter by right-clicking it at the bottom of the Data pane and selecting Show Parameter. It is now displayed...
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 $19.99/month. Cancel anytime