The Table.Repeat function in Power Query (M language) is used to duplicate a table a specific number of times and append those duplicates vertically into a single, larger table. This is primarily achieved by creating a list of the table repeated N times and then using Table.Combine to flatten that list into a single dataset. It is essential for creating dummy data, expanding small lookup tables for cross-joins, or simulating repetitive time-series intervals when a source table only contains a single period of data.

What You'll Need

  • Microsoft Excel or Power BI Desktop.
  • Access to the Power Query Editor.
  • A source table (either imported or created as a manual entry table).
  • Basic familiarity with the Advanced Editor or the formula bar, as Table.Repeat is not a button in the ribbon interface.

Step-by-Step

  1. Open the Power Query Editor: In Excel, go to the Data tab and select Get Data > Launch Power Query Editor. In Power BI, click Transform Data on the Home ribbon.
  2. Prepare Your Source Table: Ensure you have a table already loaded into the query. For this example, let's assume your current step is named Source and it contains a simple table with two columns: "Product" and "Price".
  3. Access the Formula Bar: If you do not see the formula bar above the query preview window, go to the View tab and check the box for Formula Bar. Labels and menu options may vary slightly depending on your software version or region.
  4. Create a Custom Step: Click the fx icon to the left of the formula bar. This creates a new step that references the previous step by default (e.g., = Source).
  5. Apply the Repeat Logic: You cannot use Table.Repeat as a standalone function to return a table directly because it returns a list of tables. To get a single table back, you must wrap it in Table.Combine. Replace the formula in the bar with the following syntax:
    = Table.Combine(List.Repeat(Source, 3))
    In this example, Source is the name of the previous step, and 3 is the number of times you want the table to repeat.
  6. Verify the Result: Press Enter. You should now see your original table duplicated three times, stacked one on top of the other.
  7. Rename the Step: Right-click the new step in the Applied Steps pane and select Rename. Call it "RepeatedTable" to keep your query organized.
  8. Finalize and Load: Once the duplication is verified, click File > Close & Apply (Power BI) or Home > Close & Load (Excel) to bring the expanded data into your model.

Common Mistakes

The most frequent error when using this technique is forgetting that List.Repeat returns a list, not a table. If you enter = List.Repeat(Source, 3), Power Query will display a list of "Table" objects. You will see a column containing the word "Table" multiple times. If you try to perform table operations on this result, you will receive a type mismatch error because the system expects a table but finds a list. Always remember to wrap the expression in Table.Combine() to merge those list items back into a usable tabular format.

Another common mistake is referencing the wrong step name. Power Query is case-sensitive. If your previous step is named "Source" but you write list.repeat(source, 3) with a lowercase 's', the query will fail. Always ensure the step name inside the parentheses matches the name in the Applied Steps pane exactly, including capitalization.

Users also occasionally try to use a non-integer value for the repeat count. The second argument of List.Repeat must be a whole number. If you attempt to use a decimal (e.g., 2.5), Power Query will throw an error. If your repeat count is coming from another cell or a parameter, ensure that the value is converted to an Int64.Type before being passed into the function.

Tips

To make your query dynamic, avoid hard-coding the number of repetitions. Instead, create a Parameter in Power Query (Home > Manage Parameters > New Parameter). Name it RepeatCount and set it as a Decimal or Whole Number. Then, update your formula to = Table.Combine(List.Repeat(Source, RepeatCount)). This allows you to change the number of duplicates without opening the Advanced Editor.

If you are repeating a table to create a Cartesian product (cross-join), consider adding an Index column to the original table before you repeat it. This allows you to track which original row the duplicated data came from, which is vital for auditing and data validation in complex models.

For very large tables, be mindful of memory usage. Repeating a table 100 times increases the row count linearly. If your source table has 10,000 rows, repeating it 100 times creates 1,000,000 rows. This can slow down the refresh time and increase the file size significantly. Only repeat the minimum number of times necessary for your analysis.

Troubleshooting

If the query returns an error stating "We cannot convert a value of type List to type Table," it means you missed the Table.Combine wrapper. Check your formula bar; it should start with Table.Combine( and end with two closing parentheses )).

If the table does not seem to repeat or only shows the original data, check the repeat count argument. If the number is 1, no change will be visible. If the number is 0 or negative, the resulting table will be empty. Ensure the number is a positive integer greater than 1.

If you encounter a "Token Literal expected" error, check for missing commas or mismatched parentheses. The structure must be Table.Combine( List.Repeat( TableName, Number ) ). A missing comma between the table name and the number is a common cause of syntax errors.

If the data looks correct but the column types have changed to "Any," manually re-apply the data types. Sometimes combining lists of tables can reset the explicit typing of columns. Select the columns, right-click, and choose Change Type to ensure your numbers are decimals and your dates are dates.

Frequently Asked Questions

Can I repeat a table a different number of times for each row?

No, List.Repeat applies a single uniform number to the entire table. To repeat rows based on a value within a column, you should create a custom column using {1..[RepeatColumn]} to create a list, and then expand that list to new rows.

Is there a way to repeat a table horizontally instead of vertically?

Table.Repeat (via List.Repeat and Table.Combine) only works vertically. To repeat columns horizontally, you would need to use Table.DuplicateColumn multiple times or create a custom function that iterates through a list of column names to duplicate them.

Does this function create a link to the original table or a copy?

In Power Query, this creates a transformation step. It does not create a separate physical copy of the table in memory until the query is loaded. However, any changes made to the Source step will automatically propagate to all repeated instances in the final output.

Can I use this to create a calendar table?

Yes, it is very useful for this. You can create a table with a single row containing a start date, repeat it for the number of days in a year, and then add an index column and a date addition transformation to generate a full calendar.

Will this work with tables imported from the web or SQL?

Yes. As long as the data has been loaded into the Power Query editor as a table object, the List.Repeat and Table.Combine method will work regardless of the original data source.