How to generate all combinations from two separate lists [Pivot Table Trick]
Time for a quick but very useful tip. Ever wanted to create all combinations from two (or more) lists? a la Cartesian product of both lists.
Here is a ridiculously simple way to do it.
Make Cartesian product of two tables in Excel
Note: You need Excel 2013 or above for this.
- Convert two lists to tables, if not already done.
- Select any cell in one of the tables and go to Insert > Pivot Table (Use ALT + NV shortcut)
- Make sure to check “Add this data to the Data Model” option before clicking ok.
- From your pivot table field list, switch to ALL view.
- Add both (or all fields) to row label area.
- Now, change the pivot table layout to “Show in tabular form” and check “Repeat all item labels” option.
- Turn off sub totals & grand totals.
- Viola, your cross product is ready. All combinations are generated by Excel for you. Use them as you see fit.
More fun ways to use Pivot Tables
Pivot tables versatile. You can use them to replace formulas, analyze data, create interactive dashboards and do several cool things. Check out below tutorials to get started.
- A slicer that doesn’t slice. How to fix the problem with interactive charts.
- Match debits and credits using Pivot Tables
- Select random samples from your data
- Show monthly values & % changes in one pivot report
- Find non-performing customers with pivot tables
Leave a Reply
|A quick tip about data analysis while on bike [Video + Personal]||Currency format Pivot fields with one click [Friday VBA]|