Cross-Joining Tables
This page shows how to cross-join two tables, which pairs every row of one table with every row of the other. The result is also called the Cartesian product.
A weekly budget for every store
Section titled “A weekly budget for every store”The example builds a budget table for every store in a portfolio, week by week over part of a year.
There is more than one way to do this. The approach here starts with a small table of budgets, with one record per store, and multiplies it out into a larger table that repeats those budgets for every week.
1. Budgets by store
Section titled “1. Budgets by store”Start with a simple table of each store’s budget:

A long, narrow table is usually easier to work with, so unpivot the budget columns into rows:
- Click in the table, then on Excel’s Data tab click From Table/Range.
- Right-click the Store Number column and choose Unpivot Other Columns.
- Rename the Attribute column to Budget Item.

Then save it without loading it to a sheet:
- Name the query Store_Budgets.
- Click Close & Load To, and choose Only Create Connection.
- Make sure that Add this data to the Data Model is unticked.

A connection-only query can be used by other queries without its data being stored anywhere in the workbook. Loading a query to a sheet makes a copy of its data, which takes up space, so it is worth doing only when that copy is needed. Otherwise, leave the query as a connection only.
2. Week ID numbers
Section titled “2. Week ID numbers”The budget is the same every week, and it is needed for the next 20 weeks. The weekly calendar identifies each week by a number in the form YYYYWW, so the numbers jump at the turn of the year from 201952 to 202001, as the red arrow shows.

3. Create the list of week IDs in Power Query
Section titled “3. Create the list of week IDs in Power Query”Power Query can create a list itself, without importing one from Excel, by writing it in braces. For example, = {1..5} gives the numbers 1 to 5. To build the list of weeks:
- On Excel’s Data tab, go to Get Data, then From Other Sources, then Blank Query.
- Rename the query to Weeks.
- Type this into the formula bar:
= {201944..201952,202001..202011}The two ranges, separated by a comma, give one list that skips the numbers between 201952 and 202001:

The query is a list at this point, not a table. To turn it into a table, click To Table on the Transform tab, and name the new column Week ID.

Save this query as a connection only, as well.
4. How the cross join works
Section titled “4. How the cross join works”The weeks table has 20 rows and the budget table has 10. A cross join pairs every week with the whole budget table, so the result has every combination of the two, 20 × 10 = 200 rows.

5. Cross join with a custom column
Section titled “5. Cross join with a custom column”- Open the Weeks query and add a custom column. The formula is just the name of the other query, Store_Budgets.

- Click OK. Each row of the weeks table now holds the whole budget table as a Table object.

- Click the expand icon on the new column to produce every combination. The status bar at the bottom left confirms that the query now has 200 rows.

The two tables are now cross-joined. Close & Load the query to send the result to Excel.
This example follows Matt Allington’s post Cross Join with Power Query on Excelerator BI.