I'm surprised at several levels:
(1) 2020 now .... and still no set functions in Excel
(2) The highest voted answer (from 2018) is very impractical: in real live, data sets don't come neatly with empty rows inserted where a value is missing vs. another data set; which is the precondition for this solution.
The most practical solution (though still awkward; do you hear us, Microsoft ???) is a work around with the help of a pivot table:
- Add column to set A, with column name "set_name" and all values in the column set to "A" -> pivot input A
- Add column to set B, with column name "set_name" and all values in the column set to "B" -> pivot input B
- copy pivot input B (without column names ;-)) under pivot input A to form a joint range -> joint range
- create a pivot table from the joint range with
--- "set names" being used to form the columns of the pivot table
--- pivot function set to "count()"
The result is a sort of "one-hot-encoded" pivot table with:
- 1st column: union set of A and B (aka ALL occuring values)
- 2nd column: 1-values only for elements occuring in set A
(caveat: assumption is that A only contains UNIQUE elements. Otherwise,
values > 1 are possible)
- 3rd column: 1-values only for elements occuring in set B
(same caveat applies as for set A)
- Total column: values showing "2" value exist in both sets
The resulting pivot table can easily be filtered on the different sets and intersections via the values in columns 2 (aka "set A"),3 (aka "set B") and 4 (aka "Set A AND Set B").