Hi,
Suppose I have two datasets "A" & "B". I want to compare both datasets based on property_id and merged it into another variable called "C". Conditions are as follow:
Details are below:
A: {
{user_id :null, property_id:2, active: true},
{user_id : null, property_id:4, active: true}
{user_id :null, property_id:7, active: true}
)
B: {
{user_id :100, property_id:1, active: true},
{user_id : 101, property_id:2, active: true}
{user_id :102, property_id:6, active: true}
Final Output let "C":
C : {
{user_id :100, property_id:1, active: FALSE}, /*active is FALSE as this is not exists in "A"*/
{user_id : 101, property_id:2, active: true}, /*This property_id exists in both datasets "A" & "B" hence value of user_id in "A" will be replaced by "B"s user_id value*/
{user_id : null, property_id:4, active: true} /* Nothing happens hence this is new value in "A" */
{user_id :null, property_id:7, active: true} /* Nothing happens hence this is new value in "A" */
{user_id :102, property_id:6, active: FALSE}, /*active is FALSE as this is not exists in "A"*/
}
I want store this final output in our CDT for further database operation. Appreciate your help in this regards/
Thanks
Discussion posts and replies are publicly visible
load( local!A: { { user_id: null, property_id: 2, active: true }, { user_id: null, property_id: 4, active: true }, { user_id: null, property_id: 7, active: true } }, local!B: { { user_id: 100, property_id: 1, active: true }, { user_id: 101, property_id: 2, active: true }, { user_id: 102, property_id: 6, active: true } }, { index( local!A, wherecontains( difference( local!A.property_id, local!B.property_id ), local!A.property_id ), null ), a!forEach( items: index( local!B, wherecontains( difference( local!B.property_id, local!A.property_id ), local!B.property_id ), null ), expression: { user_id: fv!item.user_id, property_id: fv!item.property_id, active: false() } ), a!forEach( items: index( local!B, wherecontains( intersection( local!B.property_id, local!A.property_id ), local!B.property_id ), null ), expression: { user_id: fv!item.user_id, property_id: fv!item.property_id, active: true() } ) } )
Thanks Krishna!