Skip to main content
Blog Dec 2, 2024 · Rahul Parmar ·6 min read

Mastering Calculations, Filters, and Aggregations in Amazon QuickSight | Armakuni

Creating effective visualizations in Amazon QuickSight requires a deep understanding of how calculations are defined, displayed, and interact with filters and data. This knowledge is essential for building high-perfor...

Mastering Calculations, Filters, and Aggregations in Amazon QuickSight | Armakuni

Creating effective visualizations in Amazon QuickSight requires a deep understanding of how calculations are defined, displayed, and interact with filters and data. This knowledge is essential for building high-performance dashboards that maximize the value of your data.

Our data and analytics expertise shows that applying the right calculation layer and level-aware aggregations in the correct order is the key to maximising data value and delivering trustworthy visualisations. Here's how you can build high-performing Amazon QuickSight dashboards.

#Types of Calculations in QuickSight

QuickSight calculations can be created at either the dataset or the analysis layer.

Misusing these layers leads to duplicate logic, performance issues, or mismatched totals.

Learn how QuickSight processes filters and calculations

Very important question: What is the evaluation order of filters and calculations in QuickSight?

Amazon QuickSight applies filters and calculations in a fixed three-step order: PRE_FILTER, PRE_AGG, and POST_AGG_FILTER, each affecting your metrics differently.

Let's explore this concept using a sales dataset with fields like Segment, Industry, Sales, and Profit. We'll demonstrate how calculations behave using additive and non-additive measures.

C4ec5e14

1. PRE_FILTER Level (Global View - Before Filters)

2. PRE_AGG Level (Analysis Filters Applied)

3. Display Level (POST_AGG_FILTER) (Final Visual Output)

How to Think About It

Additive Measures

These are metrics that can be summed or aggregated across all dimensions without losing meaning. For example, Sales and Profit are additive because their totals are meaningful when summed across rows or groups.

Example: Cost Calculation

When we create a table with Segment, Profit, Sales, Row Cost, and Aggregate Cost, both Row and Aggregate calculations produce the same results since Cost is additive.

7009186f

Best Practice: Use row-level calculations and include them in the dataset layer for precomputation during SPICE dataset refresh.

Non-Additive Measures

These metrics cannot be directly summed across dimensions as their aggregation depends on context. For example, Profit Margin (Profit ÷ Sales) is non-additive because it requires aggregation (e.g., total profit ÷ total sales) rather than summing individual margins.

Example: Profit Margin Calculation

Adding these to the table alongside Segment reveals that the Row Profit Margin is incorrect because it aggregates row-level calculations (SUM) at higher levels, distorting the results. The Aggregate Profit Margin calculates sums for Profit and Sales first and then performs the division, ensuring accurate results.

D7994736

Best Practice: For non-additive KPIs, build calculations using aggregated measures.

Implement Level-Aware Aggregations for advanced control

QuickSight provides Level-Aware Aggregations (LAAs) for advanced calculations, enabling control over how filters and aggregations interact.

Real World use case of Level-Aware Aggregations:


1. PRE_FILTER (Global Calculations)

2. PRE_AGG (Filtered Aggregations)

3. POST_AGG_FILTER (Visual-Specific Calculations)

Example: Overall Sales Calculations

We create three calculated fields:

Adding these calculations to a table alongside Industry and Sales produces the total sales across the entire dataset.

F95a67db

Initially, all three calculated fields display the total overall sales for the entire dataset. This matches the total of the Sales column in the table view.

Next, we apply an Industry filter to exclude the "Misc" category.

F268e62e

The PRE_FILTER calculation remains unchanged, as it is evaluated before analysis-level filters are applied.

The PRE_AGG, POST_AGG_FILTER, and the table total for the Sales column adjust to reflect the new total, excluding the "Misc" category.

We then apply a Top/Bottom filter to display only the top 5 industries by sales.

64f87b1f

Both PRE_FILTER and PRE_AGG calculations remain unaffected, as they are evaluated before the Top/Bottom filter is applied.

The POST_AGG_FILTER and the table total for the Sales column update to include only the sales from the top 5 industries.

Avoid these common QuickSight mistakes

  1. Incorrect Use of Row-Level Calculations for Non-Additive Measures: Applying row-level calculations to non-additive measures like Profit Margin can lead to incorrect results. Always use aggregated calculations for such measures.
  1. Ignoring Evaluation Order: Misunderstanding the order in which filters, calculations, and aggregations are applied can result in unexpected outcomes. Ensure you are aware of how QuickSight processes these elements.
  1. Overloading SPICE Capacity: SPICE has limits on data capacity. Overloading it with too many calculations or large datasets can degrade performance. Optimize your datasets and calculations to stay within SPICE limits.
  1. Not Leveraging Level-Aware Aggregations: Failing to use LAAs can limit the flexibility and accuracy of your dashboards. Understand and apply LAAs to control how filters and aggregations interact.
  1. Neglecting Data Refresh Schedules: SPICE datasets need regular refreshing to stay up-to-date. Neglecting this can lead to outdated insights. Set up a refresh schedule that aligns with your data update frequency.

Key Takeaways

Best Practices

#Build accurate dashboards with Amazon QuickSight and Armakuni

As an AWS Premier Partner with the Data & Analytics Consulting Competency, we bring deep experience in building scalable, insight-driven solutions on QuickSight. We've supported organisations across industries to move from inconsistent dashboards to trusted, well-structured reporting layers. At Armakuni, we help teams apply these principles with clarity and consistency, so their dashboards not only perform well, but also reflect the right data every time.

Related reading.

Contact Armakuni.

Most engagements start with an AWS-funded discovery. First conversation is with an engineer, not a sales exec.