3/5

wherecontains(): find the statement rows to review

Medium

An analyst checks a card statement, one row per transaction, against a watch list of merchants.

Given the merchant on every row, in statement order, return the rows to review as "Row 2", "Row 4" and so on. The row number is the position in the statement.

Watch out

  • Rows come out in statement order, not the order of the watch list.
  • A merchant that appears twice produces two rows.

Inputs

  • ri!merchants — List of Text
  • ri!watched — List of Text

ri! Rule Inputs

ri!merchantsList of Text
{
  "Cafe Rio",
  "QuickCash",
  "Book Nook",
  "QuickCash"
}
ri!watchedList of Text
{"QuickCash"}

Example 1 — A merchant seen twice

Input: ri!merchants
{
  "Cafe Rio",
  "QuickCash",
  "Book Nook",
  "QuickCash"
}
Input: ri!watched
{"QuickCash"}
Output:
{
  "Row 2",
  "Row 4"
}

Example 2 — Watch list in a different order

Input: ri!merchants
{
  "A1 Pawn",
  "Cafe Rio",
  "QuickCash"
}
Input: ri!watched
{
  "QuickCash",
  "A1 Pawn"
}
Output:
{
  "Row 1",
  "Row 3"
}

Example 3 — A clean statement

Input: ri!merchants
{
  "Cafe Rio",
  "Book Nook"
}
Input: ri!watched
{"QuickCash"}
Output:
{}

Example 4 — Nothing on the watch list

Input: ri!merchants
{"Cafe Rio"}
Input: ri!watched
{}
Output:
{}

Appian Expression Tips

  • • Use ri!variableName for rule inputs
  • • Use a!localVariables(local!x: …, body) for locals
  • • Use a!forEach(items: …, expression: fv!item) to iterate
  • • Use where() / reject(fn!isnull, list) to filter