When applying the cartesian product directive to two worksheets A and B, this directive pairs every row in worksheet B with every row in worksheet A. The resulting row set would have as many rows as the total number of rows in worksheet A multiplied by the total number of rows in worksheet B.
Consider the following worksheets Customers and Discounts.
Here is the Customers worksheet. It has 3 rows.
Here is the Discounts worksheet. It has 2 rows.
Here is the comment snippet that will direct Pebble Stream to apply the cartesian product to the Customers and Discounts worksheets. Notice the use of the "from" directive to identify the first worksheet in the cartesian product as Customers.
Resulting in the final worksheet with 6 (2 x 3) rows.
|Customer ID||Balance||Discount ID||Percentage|
Be careful with cartesian products. The number of rows it produces can grow quite quickly!
Use Case Tip
Cartesian products are great for applying multiple discounts to a customer's basket of items. Whenever you have a group of percentages that you need to apply to every item using a cartesian product is a good bet.
Updated over 1 year ago