One Table Calc To Rule Them All - WordPress.com

2 downloads 119 Views 664KB Size Report
Sales per product subcategory and region. ◉ Adds up sales for all rows in each cell. ◉ This is now combination of ro
Lilach Manheim: One Table Calc to Rule them All! databard.wordpress.com @lilachmanheim #TFFLilach

restarting every

compute using

at the level

Striking fear & anger In the hearts of young analysts across all the lands

How Tableau renders data Aka underlying data vs aggregated data

How Tableau renders data aka underlying data vs aggregated data Understanding how table calculations work with Tableau’s data aggregation is key to understanding and troubleshooting table calculations.

Let’s look at sales per region from our favorite data set… $

How does a sales order actually happen in the real world?

How does a sales order actually happen in the real world? [someone]

How does a sales order actually happen in the real world? [from somewhere]

[someone]

How does a sales order actually happen in the real world? [from somewhere]

[someone]

[buys something]

How does a sales order actually happen in the real world? [from somewhere]

[someone]

[buys something] [with some money]

$

$

Underlying Data

Order ID

Product Name

Customer Name

Region

Sales

CA-2011102652

Tenex B1-RE Series Chair Mats for Low Pile Carpets

Andy Yotov

West

91.96

CA-2011102652

C-Line Cubicle Keepers Polyproplyene Holder With Velcro Backings

Andy Yotov

West

33.11

CA-2011103219

Eldon 200 Class Desk Accessories, Black

Benjamin Farhat

East

56.52

CA-2011103317

Advantus Panel Wall Certificate Holder - 8.5x11

Don Miller

South

19.52

CA-2011103317

Luxo Adjustable Task Clamp Lamp

Don Miller

South

213.22

Underlying Data When we look at the underlying data for that customer’s order, we see a row for each product purchased in that order But when we analyze Superstore sales, we probably want to look at multiple customer orders That’s where aggregated data comes in…

Aggregated data

Sales per product subcategory ◉

Crosstab aggregates the underlying data



Adds up all rows in each product subcategory



1 “row” is now lots and lots of actual rows

Tableau sees it a little differently

Tableau sees it a little differently

Chairs {$328,449.10} Tables {$206,965.53} Bookcases {$114,880.00} Furnishings {$91,705.16}

◉ ◉

Data set with 4 rows 4 vectors of 1 element each

A (slightly) more complex example

Adding a dimension to the columns makes the view a bit more complex In our example, we’ll now be looking at total sales for each product subcategory in each sales region

A (slightly) more complex example

Sales per product subcategory and region ◉

Adds up sales for all rows in each cell



This is now combination of row & column fields



Tableau sees 4 vectors of 4 elements each

And Tableau sees… Chairs {$85,230.65, $96,260.68, $45,176.45, $101,781.3} Tables {$39,154.97, $39,139.81, $43,916.19, $84,754.56} Bookcases {$24,157.18, $43,819.33, $10,899.36, $36,004.12} Furnishings {$15,254.37, $29,071.38, $17,306.68, $30,072.73}

Table calculations allow Tableau to lookup values in multiple rows and columns



When we write calculations, we’re used to thinking about it in terms of how we want to add up the underlying rows of data



To level up on table calculations, you have to start thinking about it from Tableau’s perspective: what are the (aggregated) rows and columns in the world of this worksheet?



Anatomy of a table calculation Percent of total

Anatomy of a table calculation Percent of total

SUM([Sales])]/ TOTAL(SUM([Sales]))

Percent of total example

What percent of total sales does each product subcategory contribute?

Percent of total example SUM([Sales]) / TOTAL(SUM([Sales]))

Percent of total example SUM([Sales]) / TOTAL(SUM([Sales]))

Aggregation from 1 cell

Percent of total example SUM([Sales]) / TOTAL(SUM([Sales]))

Aggregation from 1 cell

Aggregation from multiple cells

INDEX()

The magic of the index calculation aka Tableau’s row counting function Use built-in counting functionality to: ◉ Understand how Tableau will see the data structure of your worksheet ◉ Figure out how that structure will be used to compute your table calculations