Hi Guys,
I would need to get one list of dictionaries and not two lists of dictionaries? how can I proceed?
I expect: this result
Now my code is like this: how can I fix?
a!localVariables( local!data:{date(2023,10,10),date(2024,10,10)}, local!country:{"ITALY","USA"}, a!forEach( items: local!data, expression: a!forEach( local!country, { DATA:local!data, COUNTRY:fv!item } )) )
Discussion posts and replies are publicly visible
a!localVariables( local!data: { date(2023, 10, 10), date(2024, 10, 10) }, local!country: { "ITALY", "USA" }, a!flatten( a!forEach( items: local!data, expression: a!forEach( local!country, { DATA: local!data[fv!index], COUNTRY: fv!item } ) ) ) )
Ganesh's answer above gets close but doesn't give the correct distribution of dates to countries (it just repeats the same two).
Here's my solution, which stores a reference to the current item in the outer forEach loop for reference in the inner loop (otherwise it's difficult since the loop-specific scope variables in the inner loop refer ONLY to that loop). We still of course need to call a!flatten() on the final generated list.
a!localVariables( local!dates: {date(2023,10,10), date(2024,10,10)}, local!country: {"ITALY", "USA"}, local!firstList: a!forEach( items: local!dates, expression: a!localVariables( local!currentDate: fv!item, /* we need to manually store a reference to the current outer loop item when we try to access it from the inner loop */ a!forEach( local!country, { DATE: local!currentDate, COUNTRY: fv!item } ) ) ), a!flatten(local!firstList) )
fyi:
thanks
Amazing! thank you so much