I opened a sales app that had been in production for four years and counted thirty-seven objects. Of those, twenty-two repeated the same Set Analysis expression with minimal differences: a different year, a different channel, one extra bracket. When the commercial area changed the definition of "net sales" —volume discount in, credit notes out— twenty-two formulas had to be edited by hand. QlikSense parameterised variables exist precisely so that scene does not happen, and yet almost nobody uses them. In most of the apps I review, the variable shows up as a plain text shortcut, never as what it really is: a function of your own, with arguments, that centralises a business rule in a single place in the project. That difference in concept separates an app that ages well from one that becomes unaffordable to maintain.

The real cost of the copied formula
Nobody decides to duplicate expressions. It just happens. The analyst builds a KPI that works, the manager asks for the same indicator for the export channel, and copying is faster than thinking. Six months later the app holds twelve slightly different versions of the truth.
The dbt Labs figures in their State of Analytics Engineering 2026 show that data teams spend more than 40% of their time building or repairing pipelines, and less than a fifth on analysis proper. In BI the proportion is similar, although the waste hides better: you do not see a broken pipeline, you see a dashboard that takes three days to update because somebody has to review it object by object. On top of that, 56% of practitioners flagged poor data quality as their most frequent problem. Part of that "poor quality" does not come from the source. It comes from the same metric being defined five ways inside the same application.
What QlikSense parameterised variables are
An ordinary variable stores text. When you call it with $(vNombre), Qlik replaces the name with that text before evaluating the expression. So far, a shortcut.
QlikSense parameterised variables go one step further: the stored text contains placeholders called formal parameters, written $1, $2, $3. When you call it, you pass the actual values in brackets, separated by commas. Qlik substitutes them in order and only then evaluates. In other words, you are defining a function.
There is also a special parameter, $0, which returns how many arguments the call actually received. Further down you will see that this detail lets you build optional parameters, something the official documentation mentions in passing and that in practice solves half of the real cases.
How to build QlikSense parameterised variables step by step
First: SET, never LET
This distinction costs you an afternoon the first time. LET evaluates the right-hand side and stores the result; SET stores the text as it is. For a variable with parameters you need the literal text, because the $1 must survive until the moment of the call. Therefore, always SET.
// Main tab of the load script
// vVentas(year_offset) -> net sales of the selected year, shifted
SET vVentas = Sum({<
[Anio] = {$(=Max([Anio]) + ($1))},
[Mes] = ,
[Fecha] = ,
[Trimestre] =
>} [Monto Neto]);Let us take the block apart. [Anio] = {$(=Max([Anio]) + ($1))} computes the maximum year of the current context and adds the offset received. The equals sign inside the dollar forces Qlik to evaluate the expression before injecting it into the set. The brackets around $1 are not decorative: without them, passing -1 produces an ambiguous subtraction when the argument comes from another variable.
The next three lines do something many people forget. [Mes] = , with an empty right-hand side clears the selection on that field inside the set. If the user has March selected and you are comparing full years, without that clearing you would be comparing March against March and calling it year against year. That mistake shows up in production three weeks later, when somebody filters by month.
Second: the call
// KPI: current year sales
$(vVentas(0))
// KPI: prior year sales
$(vVentas(-1))
// Percentage variance, in one readable line
($(vVentas(0)) - $(vVentas(-1))) / Fabs($(vVentas(-1)))
// Variance against two years ago
($(vVentas(0)) - $(vVentas(-2))) / Fabs($(vVentas(-2)))Look at fabs() in the denominator. With negative margins —and in agribusiness there are some— dividing by a negative value flips the sign of the variance and the chart shows an improvement where there was a disaster. That is a production detail, not a manual one.
Third: optional parameters with $0
The real case is almost never "one parameter". The commercial manager wants the same KPI sometimes by channel, sometimes consolidated. So a second parameter that filters nothing when it is absent comes in handy.
// vVentasCanal(offset [, channel])
// If the second argument is omitted, it does not filter channel
SET vVentasCanal = Sum({<
[Anio] = {$(=Max([Anio]) + ($1))},
[Canal] = {"$(=If($0 >= 2, '$2', '*'))"},
[Mes] = ,
[Fecha] = ,
[Trimestre] =
>} [Monto Neto]);$(vVentasCanal(0)) // all channels
$(vVentasCanal(0, Exportacion)) // export only
$(vVentasCanal(-1, Nacional)) // domestic, prior yearThe mechanism is simple once you see it. Qlik first expands $0 to the number of arguments received. If there were two, the condition holds and '$2' —already replaced by the real value— enters the set. If there was only one, $2 never expands, but that does not matter either: the condition fails and returns the wildcard '*', which in Set Analysis means "all values". Arguments go without quotes in the call, because they are inserted as raw text.
Business impact, which is what this is about
Let us translate. With twenty-two objects using $(vVentas(...)), redefining "net sales" takes exactly one script edit and one reload. It used to take an analyst a whole afternoon, plus the risk of leaving three objects unchanged and not finding out until the monthly meeting.
The hard benefit shows up in three places. First, maintenance time: in the apps where I have migrated to parameterised variables, definition changes dropped from hours to minutes, and that alone pays for itself. Second, consistency: the argument about "why your number does not match mine" disappears, and in practice that argument is the one that costs a BI area the most credibility. Third, delivery speed: a new KPI stops being a four-hundred-character expression and becomes a thirty-character call.
There is a fourth effect, less obvious, that strikes me as the most valuable. The variable becomes the place where the official definition lives. When finance and sales disagree about what counts as revenue, the conversation stops being about dashboards and turns into a line of script that somebody has to authorise. Data governance, in the end, is practised in details this small.
The self-service BI market will grow from 11.84 to 14.01 billion dollars between 2025 and 2026, according to The Business Research Company, with adoption rising around 31% year on year. More people touching the apps means more copies of formulas. Centralisation stops being technical elegance and becomes a condition for survival.
Common mistakes with QlikSense parameterised variables
= tells Qlik to evaluate the content immediately, and the formal parameters die right there. In the variables panel, the content goes without =.Confusing the evaluation context. The expression inside $(=...) is computed with the current selection. If you need it to be independent of what the user selects, you have to put Set Analysis inside the dollar itself. It is not intuitive and it is the number one source of KPIs that "move on their own".
Forgetting the number format. When the expansion has to produce a number that is then compared against a field, the format must match the field's. On installations with a decimal comma, an expansion returning 1.234,50 simply finds nothing. The fix is to wrap it in Num#() or force a decimal point with a # in the format.
Passing arguments in quotes. Actual values are inserted as text, so $(vVentasCanal(0,'Exportacion')) ends up generating {"'Exportacion'"}, with extra quotes, and returns zero without throwing any error. A silent zero: the worst possible outcome.
Nesting variables without documenting them. A variable that calls another that calls a third works perfectly and is impossible to debug six months later. Two levels maximum.
Best practices for QlikSense parameterised variables
- Prefix by type.
vEfor expressions,vFfor set filters,vLfor labels. A year from now you will be grateful. - A mandatory comment above every SET carrying the function signature: what each parameter does and an example call. The variable editor shows no documentation, so the script is the only place where it survives.
- A dedicated tab in the script called Business variables, separate from the technical path and connection variables.
- Version the script. Exporting the script to a repository before every definition change turns a corridor argument into an auditable history.
- Test the edge case first. Before publishing, call the variable with the minimum number of arguments and with the maximum. Half of the expansion problems show up there.
- Do not overdo it. If an expression is used only once, leave it in the object. One variable per one-off KPI is bureaucracy dressed up as architecture.
What is left when you switch off the monitor
There is a question I use to assess other people's apps and that I apply to my own: if a business definition changes tomorrow, how many places do I have to touch? If the answer has two digits, the app was not built, it was accumulated.
Parameterised variables are not a productivity trick. They are the concrete way an organisation decides that its metrics have an owner, a version and a single place where they live. Everything else, the dashboard design, the colours, the story you tell the board, rests on that. If you want to follow the full series of practical QlikSense articles applied to business, they are at hectorpincheira.com.
This week review one single app. Count how many times your sales expression repeats. The number will make you uncomfortable.




