Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Add boolean keywords to filters and expressions docs (#64592)

Robert Kosara7b47ae9236dd
diff --git a/docs/questions/query-builder/expressions.md b/docs/questions/query-builder/expressions.md
index f8ae148b25d..965308844f2 100644
--- a/docs/questions/query-builder/expressions.md
+++ b/docs/questions/query-builder/expressions.md
@@ -58,11 +58,10 @@ For example, you could create a new column that calculates the difference betwee
To do math on timestamp columns, you can use [Date functions](expressions-list.md#date-functions) like [dateDiff](./expressions/datetimediff.md).
-## Conditional operators
+## Conditional and Boolean logic operators {#conditional-operators}
+
+Comparison operators:
-- `AND`
-- `OR`
-- `NOT`
- `>`
- `>=` (greater than or equal to)
- `<`
@@ -70,6 +69,12 @@ To do math on timestamp columns, you can use [Date functions](expressions-list.m
- `=`
- `!=` (not equal to)
+Boolean operators for logical conjunction, disjunction, and negation:
+
+- `AND`
+- `OR`
+- `NOT`
+
For example, you could create a filter for customers from California or Vermont: `[State] = "CA" OR [State] = "VT"`.
You can also use conditionals with the `case` function (alias `if`):
@@ -93,6 +98,7 @@ You can refer to saved [metrics](../../data-modeling/metrics.md) and [segments](
Some things to keep in mind about filter expressions and conditionals:
- Filter expressions are different in that they must return a Boolean value (something that's either true or false). For example, you could write `[Subtotal] + [Tax] < 100`. Metabase would look at each row, add its subtotal and tax, the check if that sum is greater than 100. If it is, the statement evaluates as true, and Metabase will include the row in the result. If instead you were to (incorrectly) write `[Subtotal] + [Tax]`, Metabase wouldn't know what to do, as that expression doesn't evaluate to true or false.
+- The arguments of logic operators such as `AND` and `OR` must be Boolean. For example, '[Subtotal] < 100 AND [Tax] > 12`.
- You can use functions inside of the conditional portion of the `CountIf` and `SumIf` aggregations, like so: `CountIf( round([Subtotal]) > 100 OR floor([Tax]) < 10 )`.
## Working with dates in filter expressions
diff --git a/docs/questions/query-builder/filters.md b/docs/questions/query-builder/filters.md
index f2b9db1c659..cf78b314da1 100644
--- a/docs/questions/query-builder/filters.md
+++ b/docs/questions/query-builder/filters.md
@@ -37,7 +37,7 @@ One important thing to understand when filtering on a date column is the differe
![Filter expression](../images/filter-expression.png)
-If you have a more complex filter you're trying to express, you can pick [Custom Expression](./expressions.md) from the add filter menu to create a filter expression. You can use comparison operators like greater than, `>`, or less than ,`<`, as well as spreadsheet-like functions. For example, `[Subtotal] > 100 OR median([Age]) < 40`.
+If you have a more complex filter you're trying to express, you can pick [Custom Expression](./expressions.md) from the add filter menu to create a filter expression. You can use comparison operators like greater than, `>`, or less than ,`<`, boolean expressions like `AND` and `OR`, as well as spreadsheet-like functions. For example, `[Subtotal] > 100 OR median([Age]) < 40`.
Learn more about writing [expressions](./expressions.md) or skip right to the [list of expressions](./expressions-list.md).