QuickSight has no IF ... THEN ... ELSE keywords. Conditions go in one function, ifelse, as a list of
condition and result pairs followed by a final result for everything else. The first condition that is
true wins.
Copy and paste
One condition:
ifelse({Sales} >= 500, 'Large', 'Small')
Several conditions, checked in order:
ifelse(
isNull({Ship Date}), 'Not shipped',
dateDiff({Order Date}, {Ship Date}) <= 2, 'On time',
'Late'
)
AND, OR and NOT, with parentheses:
ifelse(({Region} = 'North' OR {Region} = 'South') AND {Sales} >= 500, 'Focus', 'Other')
Equality against a list of values, with switch:
switch({Status}, 'Shipped', 'Closed', 'Returned', 'Closed', 'Open', 'Active', 'Unknown')
Membership in a list, with in:
ifelse(in({Region}, ['North', 'South']), 'Domestic', 'Export')
On aggregated values (in an analysis):
ifelse(sum({Sales}) >= 1000, 'Above target', 'Below target')
Example
Seven orders, used across the guides of this section:
| Order ID | Customer | Region | Segment | Order Date | Ship Date | Sales | Status |
|---|---|---|---|---|---|---|---|
| 1 | Anna | North | SMB | 2026-05-04 | 2026-05-05 | 300 | Shipped |
| 2 | Anna | South | SMB | 2026-05-06 | 2026-05-11 | 500 | Shipped |
| 3 | Anna | North | SMB | 2026-05-12 | 400 | Open | |
| 4 | Bruno | North | Enterprise | 2026-05-05 | 2026-05-07 | 200 | Returned |
| 5 | Bruno | North | Enterprise | 2026-05-13 | 2026-05-14 | 150 | Shipped |
| 6 | Carla | South | Enterprise | 2026-05-07 | 2026-05-12 | 900 | Shipped |
| 7 | Dario | South | SMB | 2026-05-08 | 2026-05-08 | 50 | Returned |
The shipping status formula returns:
| Order ID | Days to ship | Shipping status |
|---|---|---|
| 1 | 1 | On time |
| 2 | 5 | Late |
| 3 | Not shipped | |
| 4 | 2 | On time |
| 5 | 1 | On time |
| 6 | 5 | Late |
| 7 | 0 | On time |
Order 3 has no ship date, so dateDiff would return null and the second condition would not be true.
Testing isNull first gives it a label of its own instead of letting it fall into Late.
The rules
- An else is required.
ifelseneeds exactly one final result. UseNULLif nothing should be returned: the AWS parameter example ends withNULL. - One type for all results. Every result must be text, or every result a number, or every result a
date. Mixing
'None'and0is an error; convert withtoStringor pick one type. - Parentheses for AND and OR. AND binds tighter than OR. The AWS reference shows how
month = 5 OR month < 3 AND year = 2000and(month = 5 OR month < 3) AND year = 2000select different rows. - Text comparisons are case-sensitive.
'north'does not equal'North'; comparetoLower({Region}) = 'north'when the source is inconsistent. - No BETWEEN. Write
{Sales} >= 100 AND {Sales} < 500. - Comments go between
/*and*/, and line breaks are allowed, so long conditions can be laid out as above.
Row level or aggregated
A formula with only row-level fields returns a value for every row and can be used as a dimension,
like the shipping status. A formula with aggregations is evaluated per group of the visual: in a table by
Region, sum({Sales}) >= 1000 is tested per region. One formula cannot mix the two:
ifelse(sum({Sales}) >= 1000, {Region}, 'Other') is rejected, and so is any condition that compares
sum({Sales}) with a plain field.
An aggregated ifelse cannot be used as a dimension either. To group customers by their total sales,
compute the total per customer first; see
how to calculate a total per customer regardless of the visual.
ifelse, switch or in
switch is shorter when every condition is “field equals value”, and in when several values share a
result. Both are case-sensitive like =. Use ifelse for ranges, nulls and conditions on more than one
field.
Checked against the Amazon Quick Sight function reference (October 2026). The example results were recomputed in DuckDB.