From pigment
Guides writing, editing, and debugging Pigment formulas including conditional logic, aggregation, time-series calculations, and dimensional transformations. Covers syntax, functions, modifiers, and performance trade-offs.
How this skill is triggered — by the user, by Claude, or both
Slash command
/pigment:writing-pigment-formulasThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
This skill provides comprehensive guidance for writing formulas in Pigment's multidimensional formula language, including formula builder tools for validation and generation.
formula_by_mapping_arrow.mdformula_conditionals_style.mdformula_modifiers.mdformula_performance_patterns.mdformula_segmentation_tiered_lookup.mdformula_writing_workflow.mdfunctions_basic_aggregations.mdfunctions_finance.mdfunctions_forecasting.mdfunctions_iterative_calculation.mdfunctions_logical.mdfunctions_lookup.mdfunctions_numeric.mdfunctions_security.mdfunctions_text.mdfunctions_time_and_date.mdThis skill provides comprehensive guidance for writing formulas in Pigment's multidimensional formula language, including formula builder tools for validation and generation. Pigment uses proprietary formula language which should never be confused with other language. Never mix Pigment formula language with other language, and never assume you know the language before reading this documentation.
CRITICAL - ABSOLUTE PROHIBITION: Pigment has its own unique formula language. You MUST NEVER write code or functions using another language being Excel, SQL, Python, JavaScript, MDX, DAX, or ANY other programming or query language. ONLY Pigment syntax exists when writing formulas.
Quoting Rules - MUST FOLLOW:
| Element | Syntax | Example |
|---|---|---|
| Metric names | Single quotes | 'Revenue', 'Total Sales' |
| Dimension names | Single quotes | 'Product', 'Country' |
| Property access | Dot notation with quotes, chainable | 'Product'.'Category', City.Country.Currency |
| Dimension items | Double quotes after dimension — MP02: literal only in VAR_ default | Month."Jan 25" only when setting a VAR_ metric default |
| String values | Double quotes | "Active", "Completed" |
Cross-app references:
'APPLICATION_NAME'::'BLOCK_NAME'.No hard-coding (MP02 — hard constraint): See modeling_principles §4. Before member-specific or time-bounded formulas, read formula_writing_workflow.md Step 2 and formula_modifiers.md (FILTER, SELECT, BY CONSTANT).
Common Mistakes:
Revenue → ✅ 'Revenue' (missing quotes)Product.Category → ✅ 'Product'.'Category' (missing quotes)Month.'Jan 25' → ✅ Month."Jan 25" (items use double quotes; in formulas use a VAR_ metric per MP02)Apply this checklist proportionally to formula complexity. Simple arithmetic between existing same-dimensioned metrics (e.g. 'A' + 'B', 'A' * 'B', 'A' / 'B') needs no performance wrapping — deliver as-is. Use the checklist as a review gate for formulas that introduce conditionals, dimensional changes, date-range logic, or that target large/sparse metrics.
Read formula_performance_patterns.md and verify:
Always check (universal):
Check when conditionals are present:
Check when date ranges are defined by Start/End:
Date >= Start AND Date < End) when PRORATA semantics applyPRORATA() to express "active within a date range" and derive booleans or numeric flags from PRORATA() using ISDEFINED/IFDEFINEDCheck when prior period lookups are needed:
Check when dimensional changes or mappings are involved:
Check when the metric is large/sparse or involves access rights:
Dimension."Item" in formulas; no DATE(...) for planning bounds; relative metric names only — see formula_writing_workflow.md Step 6 checklistFor the full date-range presence pattern (PRORATA worked examples, ISDEFINED/IFDEFINED derivation, when simple IF is acceptable), see Pattern 11 in formula_performance_patterns.md.
Key phases: Understand Context → Search Documentation → Design → Build → Optimize → Validate → Deliver
Follow the complete 8-step workflow: ./formula_writing_workflow.md
skill:planning-cycles-pigment-applications.Important: These tools are for validation and implementation when working with real formulas.
tool:validate_formula - Validate formula syntax WITHOUT applying it to any block
tool:update_list_property_formulaformula (the Pigment formula text)Previous or PreviousOf functionsRecommended Workflow:
tool:validate_formula to check syntaxtool:create_or_update_formula or tool:update_list_property_formulaHow to apply: After validation, use:
tool:create_or_update_formula with the formulatool:update_list_property_formula with the formulaThis skill focuses on formula implementation. Before writing formulas, understand foundational concepts from the modeling-pigment-applications skill:
Formulas produce results that must match the target metric or property type:
Type conversions: Use TEXT() to convert to text, VALUE() to convert to number, TIMEDIM() to convert dates to calendar dimensions. See functions_text.md and functions_lookup.md.
Reference: For detailed type selection guidance, see modeling-pigment-applications skill.
| Topic | File |
|---|---|
| Formula Writing Process | formula_writing_workflow.md |
| Conditionals style (IFBLANK, FILTER/EXCLUDE vs IF) | formula_conditionals_style.md |
| Modifiers (BY, ADD, FILTER, TOPARENTLIST, TOSUBSET, etc.) | formula_modifiers.md |
| BY with mapping metrics (->) | formula_by_mapping_arrow.md |
| Lookup Functions | functions_lookup.md |
| Numeric Functions | functions_numeric.md |
| Time and Date Functions | functions_time_and_date.md |
| Iterative Calculation (PREVIOUS & PREVIOUSOF) | functions_iterative_calculation.md |
| Logical Functions | functions_logical.md |
| Text Functions | functions_text.md |
| Performance Patterns | formula_performance_patterns.md |
->) → ./formula_by_mapping_arrow.mdLookup Functions: ./functions_lookup.md - ITEM, MATCH, SHIFT, TIMEDIM
Numeric Functions: ./functions_numeric.md - CUMULATE, DECUMULATE, MOVINGSUM, MOVINGAVERAGE, ABS, SIGN, EXP, LN, LOG, SIN, COS, SQRT, MIN, MAX, MOD, QUOTIENT, POWER, ROUND, ROUNDUP, ROUNDDOWN, TRUNC, CEILING, FLOOR, RANK, SPREAD
Time and Date Functions: ./functions_time_and_date.md - DATE, DATEVALUE, DAY, MONTH, YEAR, DAYS, NETWORKDAYS, WEEKDAY, STARTOFMONTH, EOMONTH, EDATE, INPERIOD, DAYSINPERIOD, PRORATA, MONTHDIF, FILLFORWARD, YEARTODATE, QUARTERTODATE, MONTHTODATE
Iterative Calculation: ./functions_iterative_calculation.md - PREVIOUS, PREVIOUSOF (full spec: circular dependencies, configuration, performance, debugging)
Text Functions: ./functions_text.md - TEXT, VALUE, LEN, LEFT, MID, RIGHT, LOWER, UPPER, PROPER, TRIM, CONTAINS, STARTSWITH, ENDSWITH, FIND, SUBSTITUTE, & (concatenation)
Logical Functions: ./functions_logical.md - AND, OR, NOT, TRUE, FALSE, ANYOF, ALLOF, ISBLANK, ISNOTBLANK, ISDEFINED, IFDEFINED, IF, SWITCH, IN, IFBLANK
Basic Aggregation Functions: ./functions_basic_aggregations.md - AVGOF, COUNTALLOF, COUNTBLANKOF, COUNTUNIQUEOF, SUMOF, MINOF, MAXOF, COUNTOF
Finance Functions: ./functions_finance.md - NPV, XNPV, IRR, XIRR
Forecasting Functions: ./functions_forecasting.md - FORECAST_ETS, FORECAST_LINEAR, SIMPLE_EXPONENTIAL_SMOOTHING, DOUBLE_EXPONENTIAL_SMOOTHING, SEASONAL_LINEAR_REGRESSION, STANDARD_NORMAL_DISTRIBUTION
Security Functions: ./functions_security.md - ACCESSRIGHTS, RESETACCESSRIGHTS
List subset ↔ parent remap (1:1, no aggregator): ./formula_modifiers.md — TOPARENTLIST, TOSUBSET
Before formula writing: modeling-pigment-applications (core concepts, Pigment Modeling Best Practices standards, dimensional design)
Related skills: optimizing-pigment-performance (formula optimization, sparsity management)
All generated formulas must include // comments for readability and maintainability.
Top-level comment (required):
// comment on its own line(s) immediately above the first line of the formulaPart-level comments (for non-trivial formulas only):
If comments are already present, try to maintain or enhance them. Replace them completely only if a formula update made them wrong or misleading.
Example (multi-step):
// Final revenue: actual revenue for active scenarios plus budget adjustments by category
'Revenue'[FILTER: 'Scenario'.'Active' = TRUE]
// Filter revenue to active scenarios only
+ 'Budget Adjustment'[BY: 'Product'.'Category']
// Add budget adjustments mapped by product category
Example (simple):
// Total cost: sum of fixed and variable costs
'Fixed Cost' + 'Variable Cost'
Comments must be included in the formula string passed to tool:create_or_update_formula or tool:update_list_property_formula.
Syntax:
'Revenue', 'Product'.'Category'VAR_ metric default (MP02 — see modeling_principles §4)."Active", "Completed"Modifiers:
Transaction Lists in Metrics:
'List'.'Property'[BY: ...]'Orders'.'Customer' not just CustomerITEM('List'.'TextCol', 'Dimension'.'Property')TIMEDIM('List'.'DateCol', Month)Sparsity:
npx claudepluginhub gopigment/ai-plugins --plugin pigmentProvides the mental model and architecture decisions for designing Pigment applications: dimensions, metrics, transaction lists, tables, calendars, and folders.
Provides DAX reference for Power BI measures, columns, tables: evaluation contexts, CALCULATE, time intelligence, iterators, table functions, optimization, patterns.
Guides you step-by-step through defining a business metric (aggregation) on a Honeydew entity. Covers SQL expression building and pushes to Honeydew via the MCP tools.