Forum Discussion
MarkolaKrai
Mar 07, 2023Copper Contributor
Set theory operations with dynamic arrays
I wonder if any of you have figured this out already (and i would like to have feedback about what i have done so far), i have been playing with columns of data and creating easy set theory operation...
PeterBartholomew1
Mar 07, 2023Silver Contributor
Dressing it up a bit!
Union: = SetOperateλ(setA, setB, Unionλ);
Intersection: = SetOperateλ(setA, setB, Intersectλ);
Difference1: = SetOperateλ(setA, setB, Diffλ);
Difference2: = SetOperateλ(setB, setA, Diffλ);
Symmetric difference: = SetOperateλ(setA, setB, SymDiffλ);
where
SetOperateλ
= LET(
items, VSTACK(A, B),
distinct, SORT(UNIQUE(items)),
isA, COUNTIFS(A,distinct),
isB, COUNTIFS(B,distinct),
criterion, MAP(isA, isB, Fnλ),
FILTER(distinct, criterion)
)
and
Unionλ = OR(x, y);
Intersectλ = AND(x, y);
Diffλ = AND(x, NOT(y));
SymDiffλ = XOR(x, y);