How to apply a condition of a list of numbers

I have this local variable

local!variable:
{2017,2018,2019,2020}

local!variable2:
a!forEach(
   items: local!variable,
   expression: if(fv!item<2018,"PRE-YEAR",fv!item)
 ),

I wanted a result like:

{"PRE-YEAR",2018,2019,2020}

Error:

Please help me 

  Discussion posts and replies are publicly visible

Parents Reply Children
  • ...just trying to understand your response...are you saying that the input to your rule is a list of Dictionary, but that you want to examine the value of each item as per your original code...that is, something like this:

    a!localVariables(
      local!variable: { 
        { EOMYear: 2017 },
        { EOMYear: 2018 },
        { EOMYear: 2019 },
        { EOMYear: 2020 },
        { EOMYear: 2021 }
      },
      a!forEach(
        items: local!variable,
        expression: if(
          fn!tointeger(fv!item.EOMYear) < 2018,
          "PRE-YEAR",
          fv!item.EOMYear
        )
      )
    )

    ...which results in: