In Appian, how would you generate a list of numbers from 1 to 500, and then display only every 100th number (i.e., 100, 200, 300, 400, 500) from that list using Appian expressions?
Answer
In Appian , we can use enumerate() we generate numbers and using mod we check whether number divisible by 100 and can achieved 100th number (i.e., 100, 200, 300, 400, 500) result
Step 1: Define the local variable
enumerate(500) returns the numbers 0 through 499. Adding 1 shifts every value up, so local!data becomes:
Step 2: Loop with a!forEach
a!forEach visits each number in the list. For each fv!item, mod(fv!item, 100) = 0 tests whether it divides evenly by 100. If it does, the item is returned. If not, an empty string comes back instead. The intermediate result looks like this:
Step 3: Remove the empty values with reject()
reject() drops every item for which the function returns true. isnull("") is true in Appian, so every empty string is removed and only 100, 200, 300, 400, and 500 remain.
Final code
Final output
Interview tip: you can do this without reject()
If the interviewer asks for a version without reject(), return {} instead of "" in the else branch:
The output is the same, {100, 200, 300, 400, 500}. Appian lists are flat, so an empty list contributes nothing when a!forEach combines the iteration results. Nothing needs filtering afterward, which saves a function call and a second pass over 500 items.
This only works with {}. An empty string stays in the list as a value, and so does null, which is why the first version needs reject().
Try it yourself
Change the inputs or the expression and run it to see what it returns.
Independent evaluator: it approximates the Appian expression language and may differ from a real Appian environment. Verify anything that matters. Terms