/pigment:using-formula-modifiersfrom Pigment
Applies formula modifiers (BY, ADD, REMOVE, KEEP, SELECT, FILTER, EXCLUDE, TOPARENTLIST, TOSUBSET) to align source metric dimensions with target metric dimensions. Covers aggregation, allocation, arrow-mapping syntax, and tiered lookup patterns.
Ships in Pigment. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Modifiers appear in square brackets after an expression: expression[MODIFIER: argument]. They change dimensionality or filter data so a source metric aligns with the target metric.
=).| Source→Target | Type | Modifier | Methods |
|---|---|---|---|
| N→1 | Aggregation | BY | SUM, AVG, MIN, MAX, COUNT |
| N→none | Aggregation | REMOVE | SUM, AVG, MIN, MAX, COUNT |
| N→none (filtered) | Conditional agg. | SELECT | SUM, AVG, MIN, MAX, COUNT |
| 1→N | Allocation | BY | CONSTANT, SPLIT |
| none→N | Allocation | ADD | CONSTANT, SPLIT |
| Defaults: SUM for aggregation, CONSTANT for allocation. |
Before choosing a BY method: check which dimension the metric currently has, not just which pair appears in an example below. Dimension already present → aggregating (SUM/AVG/...). Dimension missing and being added → allocating (CONSTANT/SPLIT).
Roll up from a finer dimension to a coarser one via a mapping property:
'Employee Headcount'[BY SUM: 'Employee'.'Department']
'Warehouse Capacity'[BY AVG: 'Month'.'Quarter']
'Product'.'Supplier'[BY COUNTBLANK: 'Product'.'Warehouse'] // products with no supplier assigned, per warehouse
[BY: dim.prop] removes dim and adds prop's dimension — no separate REMOVE needed. Multi-level hierarchies chain BY: 'Revenue'[BY SUM: 'Month'.'Quarter'][BY SUM: 'Quarter'.'Year'].
When a dimension-typed metric defines the mapping, BY respects its sparsity automatically — do not add IF(ISBLANK(...)) guards.
'Region Cap'[BY CONSTANT: 'Country'.'Region'] // same value to every country
'Region Revenue'[BY SPLIT: 'Country'.'Region'] // total divided equally across countries
CONSTANT copies the same value to each child. SPLIT divides equally.
If the request says "split," "distribute," "divide equally," or "spread" — use SPLIT, not the CONSTANT default.
Use arrow (->) when the mapping lives in a dimension-typed metric or you need explicit control over which dimensions are replaced, kept, or added.
Syntax: Source[BY Method: SourceDim1, SourceDim2 -> MappingMetric, ExtraDim]
-> (replace) — dimensions removed and replaced by the mapping's target dimension.-> (mapping/add) — mapping metrics/properties defining new dimensions, plus extra grouping dims.BY SUM: -> 'Map') — adds a dimension without replacing any.'Country'.'Region') for simple hierarchy lookups.// Source dims = Account, Version. Mapping dims = Account, Version, type = Segment.
// WRONG — Version silently aggregated:
'Metric_X'[BY COUNT: 'Account to Segment Map', 'Account'.'Market']
// CORRECT — Account replaced, Version preserved:
'Metric_X'[BY COUNT: Account -> 'Account to Segment Map', 'Account'.'Market']
->)| keep (ensure present) | add (after ->).ADD introduces a dimension at full cardinality — every combination. This densifies data.
'Annual Budget'[ADD: 'Month']
'Total Budget'[ADD SPLIT: 'Country']
Methods: CONSTANT (default), SPLIT. Prefer BY when a mapping exists — BY is sparse; ADD is dense. See skill:writing-performant-formulas.
'Revenue'[REMOVE SUM: 'Country']
'Revenue'[REMOVE FIRSTNONBLANK: 'Version']
Default is SUM. Removes the dimension entirely. Use REMOVE to drop an axis; [BY SUM: Dim] on an existing Dim does not remove it.
Tiered/banded lookup — assign each item to a band based on thresholds:
IF(
'DATA_Value' > 'INPUT_Tier_Threshold',
Tier
)[REMOVE FIRSTNONBLANK: Tier]
Evaluates over Account × Tier, picks the first qualifying tier per Account. Use > for floor-based, < for ceiling-based. Dimension item order determines FIRSTNONBLANK vs LASTNONBLANK. Define a catch-all tier with threshold 0 as fallback.
'Revenue'[KEEP: 'Country', 'Month']
'Revenue'[KEEP FIRSTNONBLANK ON RANK(Product): 'Country', 'Month']
Removes every dimension not listed. Methods: SUM (default), AVG, MIN, MAX, FIRST, FIRSTNONBLANK. FIRST/FIRSTNONBLANK with multiple dimensions require ON RANK(Dimension).
'Revenue'[SELECT: 'Country' = SET_Selected_Country]
SELECT filters then removes the filtered dimension(s). Methods: SUM (default), AVG, MIN, MAX, COUNT.
** If the target metric still needs this dimension, do not use SELECT.** SELECT removing a dimension and a later [ADD CONSTANT: Dim]/[BY CONSTANT: Dim] re-adding it are not inverses — CONSTANT broadcasts the one surviving value to every item on that dimension instead of restoring it only to its original item. Use FILTER instead: it keeps the dimension and blanks every non-matching item.
| Mode | Syntax | Behavior |
|---|---|---|
| Filter & remove | Metric[SELECT: Dim = item] | Filters to matching rows, removes the dimension |
| 1:1 mapping lookup | Metric[SELECT: DimA.TargetItem] | Reads value at the mapped target item |
| Aggregate & allocate | Revenue[SELECT: Month.Quarter] | Aggregates up then replicates to each source item |
| Offset | Metric[SELECT: Month - N] / Metric[SELECT: Month + N] | Each item reads the value N items earlier (- N, lag) or N items later (+ N, lead); keeps the dimension |
'Revenue'[SELECT: Month - 12] // Same month last year (keeps Month)
'Revenue'[SELECT: Month + 2] // January shows March's value (keeps Month)
'Revenue'[SELECT: 'Month'.'Quarter'] // Quarterly total replicated to each month
Use Filter & remove mode only when the target metric genuinely drops the dimension. If the target keeps the dimension, use FILTER — never SELECT followed by ADD/BY CONSTANT to put the dimension back.
Performance: SELECT is fast (parallel). PREVIOUS/PREVIOUSOF are slow (iterative) — use only when current value depends on prior. See skill:using-formula-functions.
'Revenue'[FILTER: 'Country' = SET_Selected_Country]
'Revenue'[FILTER: CurrentValue > 1000]
'Revenue'[FILTER: 'Is Active']
FILTER applies a boolean condition but keeps all original dimensions. Non-matching cells become BLANK. Shorthand: 'Revenue'[CurrentValue > 1000].
'Revenue'[EXCLUDE: 'Country' = SET_Excluded_Country]
'Revenue'[EXCLUDE: 'Country'.'Exclude from Report']
Removes rows where the condition is true. Opposite of FILTER. FILTER vs EXCLUDE blank semantics: FILTER blanks are excluded (cells outside filter become BLANK). EXCLUDE blanks are included (kept). Always prefer EXCLUDE for exclusions — FILTER: NOT(...) over a boolean that can be BLANK densifies the result.
'Revenue'[TOPARENTLIST: 'ActiveProducts'] // subset → parent (1:1)
'Revenue'[TOSUBSET: 'ActiveProducts'] // parent → subset (1:1)
Use when source and target differ only by subset vs full list, not aggregation.
Transaction lists cannot structure a metric directly. Aggregate into target dimensions with a single BY using comma-separated mapping expressions. Never chain multiple BY — it loses list properties:
// WRONG — chained BY loses list properties
'Orders'.'Amount'[BY SUM: 'Orders'.'Month'][BY SUM: 'Orders'.'Product']
// CORRECT — single BY, comma-separated
'Orders'.'Amount'[BY SUM: 'Orders'.'Customer', 'Orders'.'Product', 'Orders'.'Month']
'Orders'.'Customer'ITEM('Orders'.'ProductCode', 'Products'.'Code')'Orders'.'Month'. If the list does not have one yet, add it first (type: Dimension targeting Month, formula TIMEDIM('Orders'.'Date', Month)) — see skill:creating-transaction-lists. Do not inline TIMEDIM(...) in the BY modifier.| Context | Number/Integer | Date | Boolean | Text | All types |
|---|---|---|---|---|---|
| Aggregation (BY, REMOVE, KEEP, SELECT) | SUM*, AVG, MEDIAN, STDEVS, STDEVP, FIRSTNONZERO, LASTNONZERO | MIN, MAX | ANY, ALL | TEXTLIST | FIRST, LAST, FIRSTNONBLANK, LASTNONBLANK, COUNT, COUNTBLANK, COUNTALL, COUNTUNIQUE |
| Allocation (BY, ADD) | CONSTANT*, SPLIT | — | — | — | — |
| * = default method. |
Earliest/first event per entity: use Date[BY MIN: 'TL'.'Entity']. Prefer BY MIN over BY FIRST — BY FIRST only returns the earliest date if the dimension happens to be chronologically ordered, which is not guaranteed.
// Weighted average
('Revenue' * 'Margin')[BY SUM: Country.Region] / 'Revenue'[BY SUM: Country.Region]
// Ratio to year total — only Month grain changes
'Metric' / 'Metric'[BY SUM: Month.'Year'][BY CONSTANT: Month.'Year']
// Percentage of total
'Country Revenue' / 'Country Revenue'[REMOVE: Country]
// Aggregate a transaction list to Year via the stored Month property
'Orders'.'Amount'[BY SUM: 'Orders'.'Month'.'Year']
// Filter a transaction list before aggregating
'Orders'.'Amount'[SELECT: 'Orders'.'Date' >= DATE(2024,1,1)][BY: 'Orders'.'Month']
Two equivalent syntaxes: Block[mod1][mod2] or Block[mod1; mod2] (semicolon). Caution: chained non-commutative aggregators (e.g. [BY AVG: dim1][BY AVG: dim2]) can yield different results than [BY AVG: dim1, dim2] when blanks exist (average of averages ≠ average of all).
-> are aggregated away. If nothing is before the ->, source dimensions are kept'Country'.'Region', 'My Subset'.'Orders'.'Customer'), not just the dimension name.What SKILL.md sets; muted values are Claude Code's defaults
39 skills in this plugin
/aggregating-view-dataExecution skill. Use when a View needs totals or subtotals, when a value must roll up with something other than Sum (average, min, max, count, last), when a snapshot metric adds up across time instead of holding, or when a ratio, percentage, margin, growth or variance metric is added to a Table View or shows a wrong total (e.g. a row for margin as a percent of revenue). Covers metric default aggregators, pivot versus hidden-dimension aggregation, the aggregator reference per value type, and Advanced Aggregators on Table Views./architecting-multi-application-solutionsPlanning skill. Use when deciding how to split work across Pigment applications, designing Hub-and-spoke data flows, or planning Test & Deploy across environments./npx claudepluginhub gopigment/ai-plugins --plugin pigmentOther plugins' skills for the same job