Generate Last N Years
Easy
Given an input n, generate a list containing the last n years in chronological order, including the current year.
For example, if the current year is 2026:
- n = 5 → {2022, 2023, 2024, 2025, 2026}
- n = 3 → {2024, 2025, 2026}
Requirements
- Use Appian expression functions.
- The value of n should determine how many years are returned.
- Include the current year.
- Return the years from oldest to newest.
- Do not use reverse().
Restrictions
Solve this without using reverse().
ri! Rule Inputs
ri!nNumber (Integer)5
Example 1 — Case 1
Input: ri!n
5
Output:
{
2022,
2023,
2024,
2025,
2026
}Example 2 — Case 2
Input: ri!n
3
Output:
{
2024,
2025,
2026
}Example 3 — Case 3
Input: ri!n
8
Output:
{
2019,
2020,
2021,
2022,
2023,
2024,
2025,
2026
}Appian Expression Tips
- • Use
ri!variableNamefor 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