Given two datasubsets how do I intersect them

Certified Senior Developer

Given two datasubsets, is there a way for me to generate a third datasubset that is the intersection of their data? 

  Discussion posts and replies are publicly visible

  • Hi,

    If the two data subsets of same type you can use merge and generate third data subset of same type. Suppose both are different data subsets then you need to construct dictionary to form the third data subset

    Regards
    Swapna
  • Hi ,

    Yes, you can generate third datasubset with merging two datasubset.
    Create expression with two local variables, that can store your datasubsets, like local!a and local!b. Merge their .data properties with Merge function.This will create another list for you and with the help of todatasubset function, you can create third datasubset.

    todatasubset(merge(local!a.data,local!b.data))).

    Suggestion: Do not use use merge function for huge data or list. You will observe performance issue in your code. This is not recommended. What you can do, create a view in database for this, and call that view in expression with query entity.

    Hope it helps you.

    Thanks,
    Sandeep
  • You can use intersection function(casting might be required) -

    todatasubset(intersection(dataSubset1.data,dataSubset2.data))

    For e.g. - intersection({{a:1,b:1},{a:1,b:2}},{{a:1,b:2}})

    returns - {a:1,b:2}