Appian where()
Find the positions in a list where a condition is true. Paired with index() it is how filtering is written in Appian, and it handles the comparisons reject() cannot.
Official Appian documentationThe shape
where() takes a list of true and false values and returns the positions that were true.
where({true, false, true}) → {1, 3}Positions, counting from 1. Not the values — the places where the values were.
Where the booleans come from
You rarely type them. A comparison against a whole list produces them for you, one per item:
{60, 45, 72} >= 60 → {true, false, true}So where({60, 45, 72} >= 60) is {1, 3}: the first and third scores passed.
It gives you positions, so pair it with index()
Positions are only half an answer. Feed them to index() and you have the values:
index(scores, where(scores >= 60), 0) → {60, 72}That pairing is the standard way to filter a list in Appian, and it is worth memorising as one shape rather than two functions.
When nothing matches, where() returns an empty list, index() is handed no positions, and you get an empty list back. No special case is needed.
How this differs from reject()
reject() takes a function, so it can only ask questions some existing function already asks. where() takes a condition, so it can ask anything you can write:
index(words, where(len(words) >= limit), "")
There is no fn! for "at least this long", so reject() cannot do that at all. Between them: reject() for the tidy standard cases like dropping nulls, where() plus index() for anything with a comparison in it.
The trap: not every function spreads across a list
Comparisons do. len(), upper() and trim() do. isnull() does not.
where(isnull({1, null, 3})) → {}That looks like "no nulls found" and it is nothing of the sort — isnull() looked at the list as a single thing, decided the list itself was not null, and returned one false. Nothing warns you.
For nulls, reach for reject(fn!isnull, list) instead. Before using any function inside where(), check that it actually returns one value per item.
Try it
Run each one and read what comes back before moving on.
Start with the booleans written out by hand.
where({true, false, true})1Compare a whole list to a number and look at what you get.
{60, 45, 72} >= 602Now wrap that in where() and read the result carefully.
where({60, 45, 72} >= 60)3Turn those positions into the values.
index({60, 45, 72}, where({60, 45, 72} >= 60), 0)Try a condition nothing satisfies.
where({1, 2, 3} > 99)Look for nulls the obvious way.
where(isnull({1, null, 3}))Independent evaluator — approximates the Appian expression language and may differ from a real Appian environment. Verify anything that matters. Terms
Exercises
0 of 5 cleared- 1where(): find the positions of the passing scoresEasy
- 2where(): alert on the hours that ran too hotMedium
- 3where(): count how many meet a thresholdEasy
- 4where(): flag the messages that cannot be sentMedium
- 5where(): split a class into passed, failed and absentHard