Skip to main content

Formula basics

Learn to write formulas in Analyse data. Covers creating calculated columns, syntax for column references and operators, using autocomplete, troubleshooting errors, and handling empty values.

Updated over a month ago

Formulas let you calculate new values from your existing data. If you've used Excel, the concept will feel familiar—you write expressions that combine column values, operators, and functions to produce results. The key difference is that formulas in Analyse data apply to entire columns rather than individual cells, so a single formula calculates values for every row in your table automatically.


Where to write formulas

The formula bar is located below the toolbar at the top of your workbook. When you select a column, the formula bar displays that column's formula (if it has one). When you create a new column, the formula bar is where you'll type your calculation.

As you type in the formula bar, autocomplete suggestions appear showing function names and column names that match what you've entered. This helps you discover available functions and ensures you reference columns correctly.

Creating a calculated column

To add a calculated column to a table:

  1. Select the table in your workbook.

  2. In the Editor panel, click + next to Columns.

  3. Select Add new column. A new column appears and the formula bar becomes active.

  4. Type your formula in the formula bar. As you type, suggestions appear for functions and column names.

  5. Press Enter or click the tick (✓) to the right of the formula bar to save your formula.

  6. Double-click the column header to rename your column to something meaningful.

The column automatically populates with calculated values for every row in your table.

Basic syntax

Formulas use a straightforward syntax that combines column references, operators, and functions.

Referencing columns

To use a column's values in your formula, enclose the column name in square brackets:

[Column Name]

For example, to reference a column called "CO2 Emissions", you would write [CO2 Emissions].

Arithmetic operators

Use these operators to perform calculations:

Operator

Description

Example

+

Adds two values

[Scope 1] + [Scope 2]

-

Subtracts one value from another

[Total Emissions] - [Offsets]

*

Multiplies two values

[Quantity] * [Emission Factor]

/

Divides one value by another

[Total Emissions] / [Revenue]

^

Raises a value to a power

[Value] ^ 2

%

Returns the remainder after division

[Value] % 12

Comparison operators

Use these operators to compare values (typically within logical functions like If):

Operator

Description

Example

=

Equal to

[Status] = "Complete"

!=

Not equal to

[Category] != "Excluded"

<

Less than

[Emissions] < 1000

<=

Less than or equal to

[Score] <= 50

>

Greater than

[Intensity] > 0.5

>=

Greater than or equal to

[Progress] >= 100

Logical operators

Combine conditions using these operators:

Operator

Description

Example

AND

Both conditions must be true

[Scope] = 1 AND [Category] = "Fuel"

OR

Either condition can be true

[Status] = "High" OR [Status] = "Critical"

NOT

Reverses a condition

NOT [Is Excluded]

Joining text

Use the ampersand (&) to combine text values:

[Site Name] & " - " & [Location]

This produces results like "Factory A - Birmingham".

Column reference types

Different situations require different reference syntax.

Reference type

Syntax

Example

Use case

Same table

[Column Name]

[CO2 Emissions]

Referencing a column in the current table

Different table

[Table Name/Column Name]

[Facilities/Site Name]

Referencing a column from another table in the workbook (used with the Lookup function—see Function reference by category)

Control value

[Control-ID]

[year-filter]

Referencing the selected value from a control element

Range control minimum

[Control-ID].min

[emissions-slider].min

Getting the minimum value from a range slider or number range control

Range control maximum

[Control-ID].max

[emissions-slider].max

Getting the maximum value from a range slider or number range control

Date range start

[Control-ID].start

[date-range].start

Getting the start date from a date range control

Date range end

[Control-ID].end

[date-range].end

Getting the end date from a date range control

Understanding autocomplete

As you type in the formula bar, Analyse data suggests matching items to help you write formulas accurately:

  • Function suggestions: Type the beginning of a function name and matching functions appear. Select one to insert it with placeholder text showing the required inputs.

  • Column suggestions: Type an opening bracket [ and available column names appear. Columns from your current table display first.

  • Control suggestions: Control IDs also appear in the autocomplete list, making it easy to reference control values in your formulas.

Select a suggestion by clicking it or pressing Enter when it's highlighted. This helps prevent typos in column names and shows you which functions are available.


Common errors

When something's wrong with your formula, the formula bar displays an orange border and a warning icon. Here are the most common issues:

  1. Misspelled column names: Column references must match the exact name shown in the column header, including spaces and capitalisation. Use autocomplete to avoid typos.

  2. Missing closing brackets: Every opening bracket needs a matching closing bracket. Check that your square brackets [ ] for column references and parentheses ( ) for functions are properly paired.

  3. Type mismatches: Some operations only work with specific data types. For example, you can't add a number to text, or use a text function on a number column. Check that your formula uses compatible data types.

  4. Invalid function syntax: Functions require specific parameters in a specific order. If a function isn't working, check the function reference to confirm you're using the correct syntax.

Working with empty values

Empty cells (called Null values) require special attention in formulas. Any arithmetic operation involving a Null value returns Null as the result.

For example, if [Scope 2 Emissions] is empty for a particular row:

[Scope 1 Emissions] + [Scope 2 Emissions]

This formula returns Null for that row, even if Scope 1 has a value.

Use these approaches to handle empty values:

  • IsNull function: Tests whether a value is empty: If(IsNull([Date]), "Missing", "Present")

  • Zn function: Converts empty values to zero: Zn([Value1]) + Zn([Value2])

  • Coalesce function: Returns the first non-empty value: Coalesce([Primary], [Backup], 0)


Related articles

  • Function reference by category

  • Common formulas for Excel users

Did this answer your question?