Computed Attributes
Automatically calculate attribute values from other fields
Computed attributes automatically calculate their values from other fields in your catalog. Instead of manually combining or transforming data, you describe what you want and Emfas generates the formula for you.
Why use computed attributes
Manual data entry leads to inconsistencies. When you need "Brand - Product Name" across thousands of products, someone inevitably forgets the dash or uses lowercase. Computed attributes guarantee consistency because the formula runs the same way every time.
They're also useful for derived values that should always stay in sync. Calculate profit margins from cost and price. Build URLs from slugs. Create display titles from component parts. The computed value updates automatically when source fields change.
How it works
You describe what you want in plain language. Emfas generates a formula that calculates the value.
For example, describe "Combine the brand and product name with a dash" and Emfas creates a formula that outputs "Nike - Air Max" from the brand "Nike" and name "Air Max".
The formula runs automatically whenever you update the product. You don't need to understand the underlying expression - just describe what you want.
Creating a computed attribute
Navigate to Attributes from the side menu and click + New attribute. When creating the attribute, toggle Computed to enable this mode.
After creating the attribute, you'll see a Computed Expression section in the attribute settings.
Describing your formula
Write a plain-language description of what the attribute should calculate. Be specific about:
- Which fields to use as inputs
- How to combine or transform them
- What format the output should be in
- What to do when fields are empty
Good descriptions produce better results. Compare these examples:
| Vague | Specific |
|---|---|
| "Combine name and brand" | "Combine the brand name followed by a dash and the product name, like 'Nike - Air Max'" |
| "Calculate margin" | "Calculate profit margin as a percentage: (price minus cost) divided by price, rounded to one decimal" |
| "Make a URL" | "Build a product URL by combining 'https://store.com/products/' with the product slug in lowercase" |
Generating the formula
Click Generate after writing your description. Emfas creates a formula and shows a preview of what it produces for real items in your catalog.
Review the preview to verify the output looks correct. If it's not quite right, update your description and click Regenerate.
Preview
The preview shows how the formula works on actual catalog items. You'll see:
- The item name
- The calculated output value
This helps you verify the formula before saving. If the preview shows unexpected results, refine your description and regenerate.
Saving
Click Save when the preview looks correct. The computed attribute is now active and calculates values automatically.
Tips for better results
Write descriptions that include:
- Which fields to combine and in what order - "Start with brand, then add a dash, then the product name"
- Formatting preferences - "Convert to uppercase" or "Use a comma as separator"
- Fallback values - "If brand is empty, just use the product name"
- Examples - "The output should look like 'Nike - Air Max 90'"
The more specific your description, the better the generated formula.
Viewing the formula
Click Show expression to see the underlying formula. This is useful for understanding exactly what's happening or troubleshooting unexpected results.
You can edit the formula directly if needed, though most users never need to. The plain-language description approach handles the vast majority of use cases.
Common use cases
| Use Case | Example Description |
|---|---|
| Display titles | "Combine brand and product name with a dash separator" |
| Full URLs | "Build URL by combining 'https://store.com/p/' with the product slug" |
| Price formatting | "Format the price with a dollar sign, like '$19.99'" |
| Stock status | "Show 'Low Stock' if quantity is below 5, otherwise 'In Stock'" |
| Profit margin | "Calculate margin percentage from price and cost" |
| SEO titles | "Combine product name, brand, and category separated by pipes" |
| Slugs | "Convert product name to lowercase and replace spaces with hyphens" |
Supported attribute types
Computed attributes work with these types:
- Text - Combine fields, format strings, transform text
- Number - Calculate values, perform math operations
- Boolean - Create true/false conditions based on other fields
- Price - Calculate prices, apply discounts
- URL - Build URLs from component parts
Limitations
Computed values are read-only. You can't manually override a computed value because it's always calculated from the formula.
If you need to sometimes override values, use a regular attribute instead and populate it with automations or bulk changes.
Computed attributes depend on their source fields. If you reference a field that doesn't exist or is empty, the formula may produce unexpected results. Use fallback values in your description to handle empty fields gracefully.