Get values from nested loop

Hi,

I have 2 arrays:

local!years: {"2019", "2019", "2018", "2017"}

local!income: {1,2,3,4}

So the value in "income" is corresponding to its year in the "years".

and I want to get this data like : "year" - sum("income")

2019 - 3

2018 - 3

2017 - 4

And I am trying to loop

local!yearsUnion: union(local!years,local!years),

local!res: a!forEach(
items:local!yearsUnion,
expression: with(
local!year: fv!item,
local!impact,
a!forEach(
items: local!years,
expression:
with(
local!val: 0,

if(
local!year == fv!item,
local!val = local!val + local!income[fv!index],
local!val = local!val + 0
)
)

)
)
)

But I am not getting what I want. I can find how I can return the value from the nested loop, so to connect it with the value of the parent loop

Any suggestions?

  Discussion posts and replies are publicly visible

Parents Reply Children
No Data