12.11 Find changes through comparison

 

When comparing the contents of the key columns of two two-dimensional tables, we can first read the table data as a table sequence, and then take out the values of key column to form a set, and finally perform the operation on the two sets to obtain the result.
Here below is a data table, which stores the sales order data of 2018 and 2019 in Sheet1 and Sheet2 respectively, these two sheets have the same column structure:

imagepng

imagepng

Example 1: Find the similarities
Find out the CustomerID and ProductID that the same product is purchased in both years:

=spl("=[E(?1),E(?2)].merge@io()",Y2018!B1:C406,Y2019!B1:C1060)

imagepng

Merge the data of two years, @i means returning the common rows of the two years.

Example 2: Find the differences
Find out the order information of the new customers in 2019:

A
1 =E(‘Y2018!A1:E406’)
2 =E(‘Y2019!A1:E1060’)
3 =A2.id(CustomerID)\A1.id(CustomerID)
4 =A2.select(A3.contain(CustomerID))

A3: Subtract the CustomerIDs of 2018 from all CustomerIDs of 2019 to get new CustomerIDs
A4: Filter out the orders of new CustomerIDs from 2019 order data table

imagepng

Example 3: Find all lost CustomerIDs in 2019:

=spl("=E(?1)\E(?2)",'Y2018'!B1:B406,'Y2019'!B1:B1060)

imagepng


esProc Desktop and Excel Processing
12.10 Associate with detail table
12.12 Dynamic association operation