Set Analysis in Qlik Sense: Comparative KPIs That Transform Business Decisions - featured image

Publications

Set Analysis in Qlik Sense: Comparative KPIs That Transform Business Decisions

Hector Pincheira

Hector Pincheira

CIO | CTO
Digital Strategy & Technology Innovation

items

Why 73% of Dashboards Fail at What Matters Most: Comparing

According to a study by Gartner, 73% of the organizations that implement Business Intelligence tools fail to produce effective comparative analysis. Not because the tool cannot do it, but because nobody taught them to use its real heavy artillery. In QlikSense that artillery is called Set Analysis — and it is the difference between a decorative dashboard and a strategic decision machine.

Think of it this way: your CEO does not need to know how much you sold this month. They need to know how much you sold compared with last month, with the same period last year, and against budget. Without Set Analysis you are navigating with an incomplete map. With Set Analysis you have the full GPS of the business.

QlikSense Set Analysis - Enterprise data analysis dashboard
Comparative analysis turns data into strategic decisions

The Real Pain: Decisions Based on Isolated Numbers

I have seen industrial companies billing millions of dollars make decisions off a single number: the month's sales. No context. No comparison. No trend. It is like diagnosing someone's health by measuring only their temperature — you need blood pressure, heart rate, history.

The industry data is blunt: organizations with BI-driven strategies achieve an average ROI of 127% over three years of implementation. And companies that use BI for customer analysis report revenue growth 19% higher than their competitors. The difference lies in how the expressions feeding those analyses are built.

The most common problems I find in companies that have not mastered Set Analysis:

  • Static KPIs: they show the current number but have no point of comparison. Is $500,000 in sales good or bad? It depends on the context.
  • Manual Excel reports: the BI team burns hours building comparisons that QlikSense can calculate in milliseconds.
  • Reactive decisions: without automated YTD or MoM analysis, problems surface when it is already too late.
  • Distrust in the data: when the numbers do not match across reports, the board loses faith in the tool.

Set Analysis: The Compass Your Dashboard Needs

Set Analysis is the QlikSense mechanism that lets you define a subset of data different from the current selection. In other words, you can show last year's sales while the user has the current year selected. You can compare regions, periods, products — all in real time, all dynamic.

The basic syntax is elegant in its simplicity:

Sum( {<Campo = {Valor}>} Medida )
// Ejemplo real: Ventas del año 2025, ignorando selección actual
Sum( {<Año = {2025}>} Ventas )
// Con el identificador 1 (ignora TODAS las selecciones)
Sum( {1<Año = {2025}>} Ventas )

But the real power shows up when you combine modifiers, dollar-sign expansion functions and the AGGR() function. Let us look at the use cases that turn an ordinary dashboard into a strategic tool.

Case 1: Dynamic Year-to-Date (YTD) Comparison

YTD analysis is probably the most requested KPI on any board. The question is simple: «How are we doing this year compared with the same point last year?» The QlikSense implementation with Set Analysis is powerful:

// Ventas YTD del año actual
Sum( {<
  Año = {$(=Max(Año))},
  Mes = {"<=$(=Max(Mes))"}
>} Ventas )
// Ventas YTD del año anterior (para comparar)
Sum( {<
  Año = {$(=Max(Año)-1)},
  Mes = {"<=$(=Max(Mes))"}
>} Ventas )
// Variación porcentual YTD
(Sum({<Año={$(=Max(Año))}, Mes={"<=$(=Max(Mes))"}>} Ventas)
 -
 Sum({<Año={$(=Max(Año)-1)}, Mes={"<=$(=Max(Mes))"}>} Ventas))
/
Sum({<Año={$(=Max(Año)-1)}, Mes={"<=$(=Max(Mes))"}>} Ventas)
💡 Key point: The expression $(=Max(Año)) is a dollar-sign expansion that is evaluated BEFORE the Set Analysis. That means it always takes the maximum year available in the data model, making it fully dynamic with no hardcoded values.

Let us break down each part of the YTD expression:

  • {<...>}: The angle brackets define the set modifier — the conditions that alter the selection.
  • Año = {$(=Max(Año))}: Filters by the most recent year available. The $(= ) evaluates the expression and returns the result.
  • Mes = {"<=$(=Max(Mes))"}: Filters every month up to the current one. The double quotes inside the braces are what let you use comparison operators.

Case 2: Month-over-Month (MoM) Analysis with AGGR()

This is where Set Analysis combines with AGGR() to build genuinely sophisticated analysis. AGGR() creates a temporary virtual table — think of it as a SQL «GROUP BY» living inside an expression.

// Ventas del mes actual
Sum( {<
  Año = {$(=Max(Año))},
  Mes = {$(=Max(Mes))}
>} Ventas )
// Ventas del mes anterior
Sum( {<
  Año = {$(=If(Max(Mes)=1, Max(Año)-1, Max(Año)))},
  Mes = {$(=If(Max(Mes)=1, 12, Max(Mes)-1))}
>} Ventas )
// Top 5 productos con mayor crecimiento MoM usando AGGR
FirstSortedValue(
  Producto,
  -Aggr(
    (Sum({<Mes={$(=Max(Mes))}>} Ventas)
     - Sum({<Mes={$(=If(Max(Mes)=1,12,Max(Mes)-1))}>} Ventas))
    / Sum({<Mes={$(=If(Max(Mes)=1,12,Max(Mes)-1))}>} Ventas),
    Producto
  ),
  5
)
QlikSense Set Analysis - Comparative analysis of business KPIs
AGGR() enables detail-level comparative analysis inside expressions
💡 Key point: The AGGR() function evaluates in two steps: first it creates a virtual table with the expression grouped by the specified dimension, then the outer function (FirstSortedValue) operates on that table. It is like having a subquery inside your KPI.

Case 3: Dynamic Benchmark — Performance vs. Group Average

This is one of the most powerful analyses for operations managers. Imagine you have 5 production plants and you want to show how each one performs against the group average — without the user's selection affecting the benchmark:

// Performance of the selected plant
Sum(Produccion_Real) / Sum(Produccion_Planificada)
// Benchmark: average of ALL plants (ignores plant selection)
Sum( {1<Año = {$(=Max(Año))}>} Produccion_Real )
/
Sum( {1<Año = {$(=Max(Año))}>} Produccion_Planificada )
// Deviation from the benchmark
(Sum(Produccion_Real) / Sum(Produccion_Planificada))
-
(Sum({1<Año={$(=Max(Año))}>} Produccion_Real)
 / Sum({1<Año={$(=Max(Año))}>} Produccion_Planificada))
// Ranking of plants by efficiency using AGGR
Rank(
  Aggr(
    Sum(Produccion_Real) / Sum(Produccion_Planificada),
    Planta
  )
)

The identifier 1 before the modifier is the key here. It tells QlikSense: «Ignore absolutely every user selection and work with the complete data set». That is the difference between a benchmark that moves with every click (useless) and one that stays a fixed reference (strategic).

Case 4: Contribution Analysis with Nested Set Analysis

What percentage of total sales does each category represent? Simple on the surface, but it needs Set Analysis to be calculated correctly when there are active selections:

// Contribution percentage (respects every selection EXCEPT Category)
Sum(Ventas)
/
Sum( {<Categoria =>} Ventas )
// Cumulative contribution for Pareto analysis
RangeSum(
  Above(
    Sum(Ventas) / Sum({<Categoria=>} Ventas),
    0,
    RowNo()
  )
)
// Pareto: identify the 20% of products that generates 80% of revenue
If(
  RangeSum(Above(Sum(Ventas)/Sum({<Producto=>} Ventas), 0, RowNo())) <= 0.8,
  'Top 20%',
  'Long tail'
)
⚠️ Common error: Writing {<Categoria = {}>} (with empty braces) is NOT the same as {<Categoria =>} (without braces). The first one selects records where Category is NULL. The second one REMOVES the Category selection, which is what you need in order to calculate the total.

Business Impact: From Isolated Data to Comparative Intelligence

Implementing Set Analysis properly is not a technical exercise — it is a change in how your organization makes decisions. Companies that adopt automated comparative analysis report:

  • 40% reduction in analysis time: the comparative reports that used to take hours in Excel are now available in real time.
  • Early detection of deviations: an automated MoM analysis can flag a 15% drop in sales before the month closes, giving you time to react.
  • Elimination of bias: when the benchmark is dynamic and transparent, boardroom conversations stop being about perceptions and start being about data.
  • Accelerated BI ROI: according to industry data, organizations with strategic BI achieve a 127% ROI over 3 years and cut operating costs by 18% to 22%.

Common Mistakes and How to Avoid Them

Mistake 1: Confusing the Set Identifier

using $ when you need 1 (or the other way around) completely changes the behavior. $ represents the user's current selection; 1 represents every record in the model. For fixed benchmarks, always use 1.

Mistake 2: Dollar-Sign Expansion Without Validation

The expression $(=Max(Año)-1) can fail if the Año field holds non-numeric or NULL values. Always validate: $(=If(IsNum(Max(Año)), Max(Año)-1, Year(Today())-1)).

Mistake 3: AGGR() Without the Right Dimension

AGGR() requires the dimension to be a field that actually exists in the model. If you use a calculated expression as the dimension, performance degrades exponentially. Always use native fields from the data model.

⚠️ Common error: Don't test complex Set Analysis expressions straight onto a dashboard with millions of records. Use a small table first to validate the logic, then scale. A badly built AGGR() can freeze your app.

Implementation Best Practices

Use variables for recurring expressions. If your YTD analysis shows up in 15 dashboard objects, define the expression once as a variable. That makes maintenance easier and guarantees consistency:

// In the load script, define reusable variables
SET vVentasYTD = Sum({<Año={$(=Max(Año))}, Mes={"<=$(=Max(Mes))"}>} Ventas);
SET vVentasYTD_AA = Sum({<Año={$(=Max(Año)-1)}, Mes={"<=$(=Max(Mes))"}>} Ventas);
SET vVariacionYTD = ($(vVentasYTD) - $(vVentasYTD_AA)) / $(vVentasYTD_AA);
// In any dashboard object, simply use:
$(vVentasYTD)
$(vVariacionYTD)

Document your expressions. Every complex Set Analysis should carry a comment explaining its business purpose, not its technical mechanics. «Calculates the sales variance vs. last year through the current month» beats «Uses Max(Año)-1 with a month filter».

Build a KPI catalog. Before writing expressions, agree with the business on which comparisons matter. Not everything needs a YTD — sometimes a rolling 12 months is more useful than a calendar year.

QlikSense Set Analysis - Business performance metrics and KPIs
A well-defined KPI catalog is the foundation of any strategic dashboard

Conclusion: Set Analysis is the Language of Strategic Analysis

Mastering Set Analysis in QlikSense is not a technical luxury — it is a strategic necessity. In a world where data-driven organizations are 23 times more likely to acquire customers and 6 times more likely to retain them, the ability to build sophisticated comparative analysis becomes a direct competitive advantage.

The global Business Intelligence market will reach 54.9 billion dollars by 2029. The question is not whether your company needs comparative BI — the question is whether it will have it before your competitor does.

The next time your general manager asks you for «the sales number», answer with the number, the comparison against last year, the trend over the last 6 months and the variance against budget. That is not a report — it is business intelligence. And Set Analysis is the tool that makes it possible.

Want to go deeper into advanced QlikSense expressions? Join the Strategic Circle where we share real implementations, scripts and dashboards you can apply directly in your company.

Most Read

QlikSense Hierarchy: parent-child chart of accounts expanded by levels
QlikSense Hierarchy: the Chart of Accounts That Doesn't Add Up
QlikSense Sum TOTAL: share of each family over the total
QlikSense Sum TOTAL: the Percentage That Changes When You Filter
SAP Business One Inventory Revaluation - featured image of the tutorial
SAP Business One Inventory Revaluation: Fix Wrongly Loaded Costs
Empty chamber with wooden benches: the counterweight that required being present to be used
The Veto You Had to Say in Person: Your Decisions With No Counterweight
SAP Business One customizations - featured image of the pre-upgrade audit tutorial
SAP Business One Customizations: Pre-Upgrade Audit
SAP Business One Customer Concentration - featured image of the tutorial
SAP Business One Customer Concentration: Measure Your Risk with SQL

RELATED ARTICLES