Calculations Quiz
Calculated fields, aggregation and table calculations.
Which correctly computes overall profit ratio?
- AVG([Profit]/[Sales])
- SUM([Profit])/SUM([Sales])
- SUM([Profit]/[Sales])
- [Profit]/[Sales]
Answer: SUM([Profit])/SUM([Sales]) — Divide the totals; averaging per-row ratios weights small rows equally with large ones.
Why does SUM([Sales]) - [Cost] error?
- Cost is null
- It mixes aggregate and non-aggregate arguments
- SUM cannot subtract
- Cost is a dimension
Answer: It mixes aggregate and non-aggregate arguments — One side is one value per group, the other one value per row.
Aggregation in Tableau means:
- Splitting rows apart
- Viewing measures at higher, summarised levels
- Filtering data
- Sorting values
Answer: Viewing measures at higher, summarised levels — Placing a measure on a shelf aggregates it, usually by summing.
Disaggregating the data lets you:
- Publish faster
- View every row of the data source
- Remove filters
- Create sets
Answer: View every row of the data source — Useful when analysing a measure both independently and dependently in the view.
Table calculations are computed:
- At the data source
- On the aggregated result already in the view
- At extract refresh
- On publish
Answer: On the aggregated result already in the view — They run after the query, which is why they can only see what the view contains.
Which function converts null to zero?
- IFNULL()
- ZN()
- ISNULL()
- NULLIF()
Answer: ZN() — ZN() returns zero for a null expression, preventing gaps and broken arithmetic.
CASE is generally preferred over a long IF/ELSEIF chain because:
- It allows ranges
- It is cleaner and generally performs better for discrete matches
- It handles nulls
- It is required for strings
Answer: It is cleaner and generally performs better for discrete matches — Use CASE when matching one field against discrete values; IF for ranges and complex conditions.
Which is faster in a calculation?
- String operations
- Numeric and boolean operations
- They are identical
- Date parsing
Answer: Numeric and boolean operations — Numeric and boolean calculations evaluate considerably faster than string ones.
To use a group inside a calculation you must:
- Use an ad-hoc group
- Create the group as a field and reference it
- Publish the workbook
- Convert it to a set
Answer: Create the group as a field and reference it — Ad-hoc groups cannot be referenced in a calculation; create the grouping field first.
WINDOW_AVG(SUM([Sales]), -2, 0) produces:
- A grand total
- A three-period moving average
- A running total
- A rank
Answer: A three-period moving average — It averages the current row and the two preceding it.