pbPassingBI
/
Cleaning & preparation beginner 6 min

The Formula tool

Creating and modifying fields with expressions.

What you'll be able to do
  • Write formulas for new and existing fields
  • Use conditional logic
  • Handle nulls in expressions

Creating fields

Formula adds new fields or overwrites existing ones. One tool can hold several expressions, evaluated top to bottom — so a later expression can use a field created by an earlier one in the same tool.

[Revenue] - [Cost]
[Price] * [Quantity]
[First Name] + " " + [Last Name]

Field names go in square brackets; text literals in double quotes.

Conditional logic

IF [Revenue] > 1000 THEN "High"
ELSEIF [Revenue] > 100 THEN "Medium"
ELSE "Low"
ENDIF

Or the compact form for a two-way choice:

IIF([Revenue] > 1000, "High", "Low")

A Switch is available where you are matching one field against many discrete values.

Useful functions

CategoryExamples
StringTrim, Uppercase, Left, Right, Substring, Replace, Contains
NumericRound, Abs, Ceil, Floor, Mod
DateDateTimeNow, DateTimeAdd, DateTimeDiff, DateTimeFormat
NullIsNull, IsEmpty, Null()
ConversionToNumber, ToString, DateTimeParse

Nulls

Any arithmetic with null produces null

[Revenue] - [Discount] returns null for every row where Discount is null — quietly wiping out values that looked fine.

[Revenue] - IIF(IsNull([Discount]), 0, [Discount])

The Data Cleansing tool can replace nulls across many fields at once, which is usually tidier than doing it per formula.

Multi-Field Formula

When the same expression applies to many fields — trimming every text column, say — use Multi-Field Formula rather than adding twenty expressions. It applies one formula across a selected set, with [_CurrentField_] standing in for each.

Key points
  • One Formula tool can hold several expressions, evaluated in order
  • Arithmetic involving null yields null — guard with IsNull
  • Multi-Field Formula applies one expression across many fields
Check yourself