Calculate
Calculate(expr, modifier…) · Context
Evaluates expr with the active filter context changed by its modifiers. Three kinds of modifier:
- a bare predicate (
Sales.Region = "West") — adds a filter, intersecting with the outer context (KeepFilters(pred)is an accepted alias); RemoveFilters(dims…)— lifts user filters and grouping on the named dimensions;DateShift(col, n, unit)— shifts the date context.
Modifiers apply in category order — removals first, then added predicates, then date shifts — regardless of the order you write them. That’s what makes the override idiom work. Nested Calculate composes inside-out.
Example
Section titled “Example”// Override any dashboard Region filter (intersect would give empty):WestRevenue := Calculate([Revenue], Sales.Region = "West", RemoveFilters(Sales.Region))Without the RemoveFilters, an outer filter Region = "East" would intersect with Region = "West" and yield blank — adds never override, they narrow.
Good to know
Section titled “Good to know”- Row-level security is untouchable: no combination of modifiers can widen data past RLS.
- A predicate referencing a bare column is only legal inside
Calculate— outside it, bare columns violate aggregate closure (SQX014).