pbPassingBI
/
Calculations advanced 10 min

Calculated fields and LAA

Aggregations, table calculations, and level-aware aggregation functions.

What you'll be able to do
  • Write calculated fields at the right level
  • Use level-aware aggregation functions
  • Apply table calculations like runningSum and percentOfTotal

Field basics

Calculated fields use a function library covering aggregation (sum, avg, distinct_count), string (concat, split, toUpper), date (dateDiff, truncDate, addDateTime), and logic (ifelse, switch, isNull, coalesce).

As everywhere, a ratio must aggregate before dividing: sum(revenue) / sum(sessions), never a row-level division that gets averaged afterwards.

Dataset-level fields are shared; analysis-level fields are local. Put shared business logic in the dataset.

Level-aware aggregations

LAA functions compute at a specified level of detail rather than the visual's level — QuickSight's equivalent of Tableau's LOD expressions.

Pre-filter functions (sumOver with PRE_FILTER) evaluate before filters are applied. Pre-aggregate (PRE_AGG) evaluate after filters but before the visual's aggregation. Post-aggregate evaluate at visual level.

sumOver(sum({revenue}), [{customer_id}], PRE_AGG)

That gives revenue per customer regardless of what the visual is grouped by — the standard pattern for customer-level metrics and percent-of-total denominators.

Table calculations

Post-aggregate window functions operate on the result set: runningSum, percentOfTotal, difference, percentDifference, rank, denseRank, lag, lead, windowAvg, windowSum.

runningSum(sum({sales}), [{order_date} ASC], [{region}])

The second argument is the sort order; the third is the partition, which is where the calculation resets. Getting the partition wrong produces a plausible but incorrect chart — the same failure mode as Tableau's addressing and partitioning.

Parameters and controls

Parameters hold a value — string, integer, decimal or datetime, single or multi-value — set by a control or passed in via a URL or embedding.

They drive dynamic filters, metric switching via ifelse, threshold lines, and cascading controls where one parameter narrows the options of another.

Parameters passed through embedding URLs are how a host application pre-filters a dashboard for its user.

Key points
  • Level-aware aggregations are QuickSight's LOD equivalent, with PRE_FILTER / PRE_AGG levels
  • Table calculations take a sort order and a partition — the partition is where it resets
  • Parameters can be set by controls or passed in via embedding URLs
Check yourself