Function withReplacedFormulaFilter Beta
withReplacedFormulaFilter(
match,newFilter):CalculatedMeasureTransformer
Returns a transformer that replaces the filter(s) matching the target with a new filter, keeping the same context key so the formula expression is left untouched.
Returns the measure unchanged when nothing matches; use withFormulaFilterFor when you want a missing filter to be added instead.
Parameters
| Parameter | Type | Description |
|---|---|---|
match | FormulaFilterMatcher | How to target the filter to replace. See FormulaFilterMatcher. |
newFilter | Filter | The replacement filter. |
Returns
A transformer producing the updated calculated measure.
Example
Swap the filter for an attribute, keeping the formula expression unchanged:
const forLaptops = withReplacedFormulaFilter(
DM.Category.Category,
filterFactory.members(DM.Category.Category, ['Laptops']),
)(revenue);