OriginalPostID-164186
Discussion posts and replies are publicly visible
Usually i'd suggest starting a new topic for this question since it doesn't really have much in common with the use case being asked about in the original thread from 2 years ago.
However I believe I have a workable solution (assuming you're using 17.2 or newer), so here goes:
with( local!dataset1: { { UserName: "Smith", Position: "Manager" }, { UserName: "Johnson", Position: "Cashier" }, { UserName: "Apple", Position: "Merchandise" } }, local!dataset2: { { Name: "Smith", Age: 40 }, { Name: "Johnson", Age: 23 }, { Name: "Baker", Age: 54 } }, a!forEach( local!dataset1, { NewDatasetName: fv!item.UserName, NewDatasetPosition: fv!item.Position, NewDatasetAge: with( local!dataset2Index: index(where(local!dataset2.Name = fv!item.UserName), 1, null()), if( isnull( index( local!dataset2.Age, local!dataset2Index, null() ) ), "N/A", local!dataset2[local!dataset2Index].Age ) ) } ) )
Note that this example iterates over "dataset1" and creates a new dictionary for only the entries found in it. If there are any entries in "dataset2" not mentioned in the other one, they will not be reflected in the new dictionary.
Results: