Tableau Desktop Cookbook Quick & Simple Recipes to Help You Navigate Tableau Desktop Lorna Brown Tableau Desktop Cookbook Quick & Simple Recipes to Help You Navigate Tableau Desktop Lorna Brown Tableau Desktop Cookbook by Lorna Brown Copyright © 2021 Lorna Brown. All rights reserved. Printed in Canada. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://oreilly.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or [email protected]. Acquisitions Editor: Angela Rufino Indexer: nSight, Inc. Development Editor: Michelle Smith Interior Designer: David Futato Production Editor: Katherine Tozer Cover Designer: Karen Montgomery Copyeditor: nSight, Inc. Illustrator: Kate Dullea Proofreader: Sharon Wilkey September 2021: First Edition Revision History for the First Edition 2021-08-02: First Release See http://oreilly.com/catalog/errata.csp?isbn=9781492090113 for release details. The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. Tableau Desktop Cookbook, the cover image, and related trade dress are trademarks of O’Reilly Media, Inc. The views expressed in this work are those of the author, and do not represent the publisher’s views. While the publisher and the author have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the author disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights. 978-1-492-09011-3 [MBP] Table of Contents Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi Part I. Starting at the Very Beginning 1. Introduction to Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.1 Connecting to Data 3 1.2 Searching for Data 4 1.3 Connecting to a File 5 1.4 Messy Data Sources 12 1.5 Connecting to a Server 16 1.6 Saved Data Sources 18 1.7 Connecting to Secondary Data Sets: The Data Model 19 Creating Relationship Calculations 24 Unioning Your Data: The Physical Layer 28 Joining Your Data: The Physical Layer 32 1.8 Data Types 36 1.9 Creating Extracts 38 Summary 40 2. Getting Started with Tableau. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 2.1 Creating a New Worksheet 41 2.2 The Tableau Workspace 46 2.3 The Data Pane 47 2.4 Dimension Versus Measure 50 2.5 Discrete Versus Continuous 51 2.6 Calculated Fields 54 iii 2.7 Shelves and Cards 59 Rows and Columns 59 Marks Card 62 Filters Shelf 67 Continuous Filters 72 2.8 What Is Show Me? 76 2.9 Formatting in Tableau 80 Summary 85 Part I Conclusion 85 Part II. Building a Foundation 3. Bar Charts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 3.1 Horizontal Bar Chart 89 Adding a Constant Line 94 Changing to a User-Controlled Reference Line 95 Adding Color to a Parameterized Reference Line 98 Adding Average Lines 100 3.2 Grouping 103 Visual Grouping 106 Discrete Grouping 107 3.3 Top N Filter 114 3.4 Stacked Bar Chart 117 3.5 100% Stacked Bar Chart (Percent of Total) 124 3.6 Discrete Bar in Bar Chart 130 3.7 Shared Axis 132 3.8 Shared Axis Bar in Bar 135 3.9 Bullet Chart 137 3.10 Histogram 142 3.11 Soundwave 145 Summary 150 4. Text. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 4.1 Tables 151 4.2 Adding Totals 153 4.3 Highlight Tables 156 4.4 Rank Tables 160 4.5 Big Actual Numbers 165 4.6 Calculating Percent Difference 170 4.7 Using LAST and Hide 174 iv | Table of Contents 4.8 Custom Number Format 177 4.9 How to Zero Nulls 180 4.10 Showing Positive, Negative, or Neutral Values 181 4.11 Calculating a Good, OK, or Bad Status 183 4.12 Using Titles as BANs 184 4.13 Using SIZE 187 4.14 Word Cloud 188 Summary 190 5. Lines. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 5.1 Line Charts 191 5.2 Continuous Line Charts 196 5.3 Trend Lines 200 5.4 Forecasting 202 5.5 Custom Date Format 204 5.6 Running Total 206 5.7 Year over Year Growth 210 5.8 Year to Date (YTD) Growth 213 5.9 Moving Average 216 5.10 Slope Chart 219 5.11 Sparklines 223 5.12 Small Multiple Line Charts 226 5.13 Small Multiple Controlled Version 234 Summary 238 6. Basic Mapping. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239 6.1 Symbol Map 239 6.2 Filled Map 245 6.3 Dual-Axis Map 249 6.4 Mapping Nongeographic Fields 254 Summary 257 7. Basic Dashboards. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259 7.1 Build a Basic Dashboard 259 7.2 Adding Basic Dashboard Interactivity 268 7.3 Objects 277 Using Horizontal and Vertical Containers 277 Adding a Text Object 285 Adding an Image Object 288 Adding a Blank Object 293 7.4 Layout Tab 295 Table of Contents | v Borders 295 Background 297 Using Padding 301 Item Hierarchy 303 Summary 306 Part II Conclusion 306 Part III. Broadening Your Data Viz Knowledge 8. Square. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309 8.1 Treemaps 309 8.2 Calendar Heatmap 317 8.3 Marginal Bar Charts 323 Summary 333 9. Tooltips. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335 9.1 Basic Tooltips 335 9.2 Viz in Tooltips 342 9.3 Multiple Layout Viz in Tooltip 346 Summary 350 10. Area Charts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351 10.1 Basic Area Charts 351 10.2 Stacked Area Charts 355 10.3 Percent of Total Area Charts 360 10.4 Discrete Area Charts 363 10.5 Pareto Charts 367 Summary 382 11. Circles, Shapes, and Pies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383 11.1 Scatter Plot 383 11.2 Using Custom Shapes 386 11.3 Density Marks 387 11.4 Clustering 390 11.5 Trend Lines 395 11.6 Explain Data 399 11.7 Connected Scatter Plot 401 11.8 Dot Plot 408 11.9 Dot Strip Plot 414 11.10 Jitter Plot 416 vi | Table of Contents 11.11 Box Plots 420 11.12 Using Shapes for BANs 425 11.13 Pie Charts 430 11.14 Donut Chart 433 Summary 439 12. Gantt. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441 12.1 Basic Gantt Charts 441 12.2 Barcode Charts 445 12.3 Waterfall Charts 448 Summary 455 13. Stories. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457 13.1 Creating a Story 457 13.2 Adding a New Story Point 467 13.3 Blank Story Point 469 13.4 Duplicate Story Point 470 13.5 Annotations on a Story 471 13.6 “Save as New” Story 473 Summary 475 Part III Conclusion 475 Part IV. Advancing Your Techniques 14. Sets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479 14.1 General Set 480 14.2 Conditional Set 482 14.3 Top N Set 486 14.4 Combined Set 488 14.5 Constant Set 493 14.6 Set Control 496 14.7 Set Actions 499 Summary 503 15. Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505 15.1 Float/Integer Parameter 505 15.2 String Parameter 510 15.3 Date Parameter 514 15.4 Measure Switcher 518 15.5 Dynamic Scatter Plot 521 Table of Contents | vii 15.6 Dimension Switcher 523 15.7 Parameter Actions 529 15.8 Parameter Actions: Drill Down 537 15.9 Parameter Actions: Min and Max Date Range 542 Summary 547 16. Advanced Table Calculations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 549 16.1 Previous Value 550 16.2 Lookup 555 16.3 Window Calculations 558 16.4 How to Create a Control Chart 561 Summary 566 17. Level-of-Detail Calculations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 567 17.1 Include LOD 569 17.2 Exclude LODs 573 17.3 Fixed LODs 577 17.4 Nested LODs 581 Summary 585 18. Advanced Mapping. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 587 18.1 Density Marks 587 18.2 MakePoint 590 18.3 MakeLine 593 18.4 Marks Layer 596 18.5 Distance 602 18.6 Buffer 604 18.7 Spatial Joins 606 Summary 609 19. Advanced Dashboarding. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 611 19.1 Actions 611 Highlight Action 611 URL Action 616 19.2 Dashboard Objects 622 Navigation Button 624 Download Object 626 Extensions 630 19.3 Floating 636 19.4 Toggle Containers On and Off Using Show/Hide 637 19.5 Device-Specific Dashboards 643 viii | Table of Contents