CHAPTER 11:
CUSTOMIZING YOUR
DATA
1
Customizing Your Data
■ Where calculations occur in Tableau
■ Creating & editing calculations
■ Aggregation, LODs, and table calcs
■ Hands-on practices (Profit Ratio, Overall
Profitability, % of Category)
2
Where Do Calculations Occur?
■ Database (Live): pushdown row-level & some
aggregates
■ Hyper (Extract): columnar engine, fast analytics
■ Viz Layer: aggregate calcs, LODs, table
calculations
3
Tableau Order of Operations
(High-Level)
■ Extract/Source Filters → Data Source Filters
■ Context Filters → Top N / Conditional
■ Dimension Filters → Measure Filters
■ FIXED LOD before Include/Exclude LOD
■ Table Calcs happen last, after aggregation
4
Types of Calculations
■ Row-Level: [Profit] - [Discount]
■ Aggregate: SUM([Profit]) / SUM([Sales])
■ Table Calculation: RUNNING_SUM(SUM([Sales]))
■ LOD Expressions: {FIXED [Region]:
SUM([Profit])}
5
Creating & Editing Calculated
Fields
■ Data pane → Right-click → Create →
Calculated Field
■ Name clearly; use comments //
■ Validation & data type at the bottom
■ Reuse with folders & descriptions
6
Join Calculations
■ Build join keys with calcs (e.g.,
UPPER(TRIM([State])))
■ Use Data Source view → Join Clause → Create
Join Calculation
■ Normalize different systems: codes vs names
7
Calculations & Aggregations:
Rules of Thumb
■ Don’t mix aggregated & non-aggregated fields
(wrap with MIN/ATTR)
■ Prefer SUM/AVG explicitly vs default aggregation
■ Control nulls: ZN(), IFNULL()
■ Use ATTR() to safely reference a dimension in an
aggregate calc
8
LOD vs Table Calculation
■ LOD: pre-viz aggregation (query time)
■ Table Calc: post-viz, depends on
addressing/partitioning
■ Choose LOD for stable denominators; table calc
for running totals, moving avg
9
Profit Ratio (Definition)
■ Profit Ratio = SUM([Profit]) / SUM([Sales])
■ Format as percentage
■ Works at any view level (segment, category, etc.)
10
Practice: Calculations &
Aggregations in Profit Ratio
■ Create Profit Ratio calc
■ Build view by Segment/Category
■ Validate with grand totals
11
Calculations Performed on the
Database
■ Live connections push down row-level and some
aggregates
■ Use Custom SQL or RAWSQL functions for DB-
specific logic
■ Beware of portability & security
12
Overall Profitability (Concept)
■ Compare overall profit ratio vs slice profit ratio
■ Use FIXED LOD to create a stable overall
denominator
■ Example: {FIXED : SUM([Profit])}/{FIXED :
SUM([Sales])}
13
Practice: Calculation &
Aggregation in Overall
Profitability
■ Build overall ratio via LOD
■ Compare per Segment vs overall (reference line or
KPI)
14
Aggregating Dimensions in
Calculations
■ Turn dimension totals into denominators (via LOD)
■ Use ATTR([Dim]) or MIN([Dim]) to reference dims
in aggregate calcs
■ Common pattern: “% of Category” at Sub-
Category level
15
Practice: Aggregating
Dimensions in Calculations
■ Compute % of Category Profit at Sub-Category
level
■ Validate behavior when changing the view
16
Debugging & Testing Calculations
■ Show View Data & Row Counts
■ Use Annotations/Labels to print intermediate calcs
■ Describe Field to verify data types
■ Build QA sheets for totals & sanity checks
17
Naming, Docs, and Governance
■ Prefix by type: LOD_, Agg_, TC_
■ Add Descriptions; group in folders
■ Review with peers; lock trusted calcs in certified
sources
18