# How to calculate values and format numbers in templates

URL: https://help.hubhus.com/kb/how-to-calculate-values-and-format-numbers-in-templates
Category: Campaigns & Lead Management / Templates
Updated: 2026-09-28T14:40:41.064+00:00

Summary: Simple calc: @calc&#91;(2+2)*3&#93;@endcalc . Formatted calc: &lt;hh-calculator precision="2" decimalSeparator=",">(1250.75 + 249.25) / 2&lt;/hh-calculator> . Percentage: &lt;hh-calculator.percentage>25% of %lead_price%&lt;/hh-calculator.percentage> . Number format: &lt;hh-number.format input-decimal-separator="." output-decimal-separator="," decimals="2" /> . Use with lead field placeholders for dynamic pricing.

Hubhus includes built-in calculators for performing math and percentage calculations directly in templates, booking forms, automations, and HTML components - without external code.

## 4 calculation tools

1. **@calc - basic calculation**. The simplest calculator. Supports +, -, *, /, and parentheses. Example: `@calc[(%lead_price% * 1.25)]@endcalc` - multiply price by 1.25 (add 25% VAT). Output is raw number without formatting. Use when you only need the value without decimal control.
2. **hh-calculator - formatted calculation**. Supports the same operations as @calc but with precision and formatting control. Attributes: `precision="2"` (decimal places), `decimalSeparator=","` (Danish comma), `thousandsSeparator="."`. Example: `<hh-calculator precision="2" decimalSeparator=",">%lead_price% + %lead_fee%</hh-calculator>`Use for currency output in emails and webpages.
3. **hh-calculator.percentage - percentage calculations**. Specialized for percentage expressions. Supports: "x% of y", "x% discount on y", "Add x% to y". Example: `<hh-calculator.percentage precision="2" decimalSeparator=",">25% of %lead_price%</hh-calculator.percentage>`Ideal for VAT calculations, discounts, commissions, and dynamic quotes.
4. **hh-number.format - number formatting**. Format an existing numeric value without calculating. Attributes: `input-decimal-separator`, `output-decimal-separator`, `decimals`. Example: `<hh-number.format input-decimal-separator="." output-decimal-separator="," decimals="2">%lead_price%</hh-number.format>`Use to ensure consistent currency display when the stored value uses a different decimal format.

**Read more**

### Full example: price calculation in email templates

**Sum of two lead fields:**

```
Your total price is:
<hh-calculator precision="2" decimalSeparator=",">
    %lead_base_price% + %lead_installation_fee%
</hh-calculator> kr.
```

**Percentage discount applied:**

```
Applied discount:
<hh-calculator.percentage precision="2" decimalSeparator=",">
    10% discount on %lead_total_price%
</hh-calculator.percentage> kr.
```

**VAT calculation (add 25%):**

```
Price incl. VAT:
<hh-calculator precision="2" decimalSeparator=",">
    %lead_price% * 1.25
</hh-calculator> kr.
```

### Using calculations in booking forms

Calculator components can be placed inside booking form HTML components or confirmation texts. Common use cases:

- Showing dynamically calculated prices during the booking flow
- Summing selected add-ons or extras
- Calculating estimated duration or hours
- Displaying totals at the confirmation step

**Where to place calculator components in booking forms:**

- **Part 3** (confirmation step) - show price summary before the customer submits
- **Part 4** (after booking is completed) - show final receipt
- Inside HTML components that are reused across multiple booking forms

**Important:** Decimal separators must be consistent across all connected calculations. Use `decimalSeparator=","` for Danish formatting and `decimalSeparator="."` for international formatting - do not mix within the same calculation chain.

## Related articles

- https://help.hubhus.com/kb/how-to-format-dates-and-calculate-time-differences
- https://help.hubhus.com/kb/hh-components-reference-guide
- https://help.hubhus.com/kb/understanding-placeholders-and-dynamic-content
- https://help.hubhus.com/kb/creating-a-quotation-line-generator-with-visual-presentation
