Skip to main content

Astrato Parameters & Variables, and when to use each

This guide explains the difference between variables and parameters in Astrato and how they work together to create dynamic, context-aware analytics.

Piers Batchelor avatar
Written by Piers Batchelor
Updated yesterday

Overview

In Astrato, variables and parameters work together to make analytics dynamic and context-aware.

  • Variable = the value that can change during a user session

  • Parameter = the placeholder that receives that value inside the semantic model / SQL

Think of a parameter as the socket and the variable as the plug.

Variables drive interactivity across the workbook. Variable can also be nested inside other variables usinf $() notation, Dashboard: $(vCurrentSheet).

They store values that can be:

  • selected by a user

  • set by an action

  • controlled by embedding context

  • written back to a database

  • set to trigger actions on value update

What they control

  • Filters

  • Measures

  • Dimensions

  • Writeback context

  • Navigation & actions

  • Row-level logic (via semantic layer)

Typical use cases

  • Retrieve current customer name, group, date

  • Scenario selection

  • Currency / unit switch

  • Date comparison mode

  • “View as” user or role

  • Dynamic measure selector

  • Controlling writeback visibility

  • Toggle between chart types

  • Show / hide components

  • Storing SQL, which can be run using the Execute SQL action block


Parameters

Parameters are "placeholders" that receive a value when the paramter is used, they can utilize a default value, a custom value, or a value linked to a variable. Parameters are available in custom SQL and in measures created in the Semantic Layer.

Global Parameters | User Attributes

Admins can assign and persist Global Parameters directly on user profiles from the admin portal, a fast alternative to managing user-specific parameters via actions or API. Not only is UI editing supported, but also bulk upload via CSV/XLSX.

Use cases:

• Pre-filter data per user (e.g. region, team, customer)

• Personalised row-level access for embedded and internal analytics without reliance on database user/role linking

• Default dashboard settings or layout per user

• Auto-scoped operational dashboards (e.g. a manager only sees their stores on open)

• Feature flags to control beta access or workbook variants by user

• Sales and customer success views preloaded with their own account portfolio


Example use

The user-parameter is automatically linked to any parameters of the same name and type. For example, in the semantic layer.

[1] Setup the user parameter

[2] Set a table filter, using a the same parameter name in the Semantic Layer.

This will pass any user-level parameter values, where the parameter name is the same.


Parameter file upload

An example structure for file upload is as follows:

name

type

value

email

MeasureParam

float

12

MeasureParamFilter

string

Rocco Neubert

Excluded_Sales_Agent

string

Rosalina Dieter, Wilburn Farren

MeasureParamFilterDate

date

2017-04-20

MeasureParamFilterInt

int

4

MeasureParamFilterBool

boolean

FALSE

YearParam

int

1994, 1997

MeasureParam

float

12

MeasureParamFilter

string

Rocco Neubert

Excluded_Sales_Agent

string

Rosalina Dieter, Wilburn Farren

MeasureParamFilterDate

date

2017-04-20

MeasureParamFilterInt

int

4

MeasureParamFilterBool

boolean

FALSE

YearParam

int

1994, 1997

Measure parameters open an opportunity for end-users to change the result of a measure by changing the parameter values.

SQL Parameters (and why they matter in Astrato)

Using parameters in SQL gives you control, speed, and safety. Parameters turn SQL from fixed code into a flexible engine that users can control.

Here are the real, practical wins:

One query, many uses
Write logic once and reuse it everywhere.
Change a value/filter without rewriting SQL.

Example:

  • Change date range

  • Adjust filters in real time

Faster to build and maintain
Instead of 10 almost-identical queries, you have 1 smart query.

Less code = fewer bugs and less upkeep.

Better performance
Instead of running big generic queries and filtering after, parameters push filters into the SQL itself.

That means:

  • Smaller result sets

  • Faster queries

  • Less warehouse cost

  • Better pruning on clustered tables

What it does

When the view runs, Astrato swaps in the actual values — from users, variables, controls, or defaults — to generate the final query.

How it works

  • Supported for Custom SQL views (sourceType: "statement").

  • Declare parameters inline using {name:type} — e.g. {store_id:int}, {from_date:date}.

  • Types include string, int, float, boolean, date, and more.

  • Astrato auto-parses all parameters and handles substitution at runtime.

Example

A view with source: SELECT * FROM users WHERE age > {min_age:int} AND status = {user_status:string}

Parameters:

  • min_age: int

  • user_status: string

This allows one reusable view to power many scenarios — filters, what-if inputs, user-personalised data slices — all without duplicating SQL.

In each object, you can link a variable (or hardcode a value) to each parameter you have in use.


How they work together

  1. Variable gets a value in the workbook

  2. Variable is mapped to a parameter

  3. Parameter injects the value into the semantic model query

If a parameter is not mapped, its default value is used.

Naming best practice

Use identical names for variables and parameters.

Why:

  • Avoid manual mapping

  • Prevent falling back to default parameter values

  • Faster model setup

  • Lower risk of deployment mistakes

If names differ → manual mapping is required (works fine, easier to forget).

Did this answer your question?