Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Power Query List.Split: Step-by-Step Guide

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

List.Split takes a list and breaks it into a list of smaller lists, each with a set number of items. You give it the source list and a page size, and it returns the chunks. This is useful for batching API calls, splitting long text into fixed-size groups, or preparing data for pagination. You need Power Query in Excel or Power BI, and a list to work on. No special setup beyond that.

What You'll Need

  • Power Query Editor open in Excel (Data > Get Data > Launch Power Query Editor) or Power BI Desktop (Home > Transform data). Menu labels can differ slightly by version, device or region.
  • A list value to split. This can come from a column, a manual list, or a function like Text.ToList.
  • Basic familiarity with the formula bar and the Advanced Editor.

Step-by-Step

  1. Create or load a list. In Power Query, a list is a single-column table without headers, or a value of type list. For a quick test, open a blank query (Home > New Source > Blank Query) and in the formula bar type = {1..10}. Press Enter. You now have a list of numbers 1 through 10.
  2. Open the Advanced Editor. With the query selected, go to Home > Advanced Editor. This shows the M code. If you used the blank query, you will see something like let Source = {1..10} in Source.
  3. Add a step that calls List.Split. After the Source step, add a comma and a new line: Split = List.Split(Source, 3). Then change the final in to return Split. The full code becomes:
    let
        Source = {1..10},
        Split = List.Split(Source, 3)
    in
        Split
    Click Done. The query now returns a list of lists: each inner list has up to 3 items. The last chunk may have fewer if the total is not divisible by the page size.
  4. Convert the result to a table to inspect it. With the list selected, go to Transform > To Table. In the dialog, leave the default (it will use Column1). You now see a table where each row contains a list. Click the expand icon next to the column header and choose Expand to New Rows. This flattens the chunks back into a single column, which is useful for checking that the split worked as expected.
  5. Use List.Split on a column. If your list comes from a table column, first drill down to the list. For example, if you have a table with a column named Values, add a step: MyList = Table.Column(PreviousStep, "Values"). Then call List.Split(MyList, 5). You can then convert back to a table as above.
  6. Handle the remainder explicitly. List.Split always includes the final partial chunk. If you need to drop incomplete chunks, wrap the result in List.Select: List.Select(List.Split(Source, 3), each List.Count(_) = 3). This keeps only full chunks. Use this when a downstream step requires exactly the page size.
  7. Test with edge cases. Try an empty list {}, a list with one item, and a page size larger than the list. List.Split returns an empty list for an empty input, and a single chunk for the others. Confirm your downstream steps handle these cases.

Common Mistakes

  • Passing a table instead of a list. List.Split expects a list. If you pass a table, you get an error. Use Table.Column or Table.ToList to extract a list first.
  • Forgetting that the last chunk can be smaller. Many people assume every chunk has exactly the page size. If your logic depends on that, filter the result as shown in step 6.
  • Using a page size of zero or negative. List.Split requires a positive integer. Zero or negative values cause an error.
  • Confusing List.Split with Text.Split. Text.Split works on text values, not lists. Use List.Split for lists.
  • Not handling nulls. If your list contains nulls, they are treated as items. List.Split does not skip them. Clean or filter nulls before splitting if needed.

Tips

  • Use List.Split to batch API calls: split a list of IDs into chunks of 100, then call a web function for each chunk. This avoids hitting request limits.
  • Combine with List.Transform to process each chunk, for example to sum each group or convert each chunk to text.
  • If you need to split text into fixed-length lines, first use Text.ToList to get a list of characters, then List.Split, then Text.Combine on each chunk.
  • Keep the page size as a variable at the top of your query so it is easy to change later.
  • Use the formula bar to experiment quickly: type = List.Split({1..10}, 3) in a blank query to see the result immediately.

Troubleshooting

If you get an error saying the argument is not a list, check the type of your input. In the formula bar, the step before List.Split should return a list. You can verify by clicking the step and looking at the icon in the query pane. If it shows a table, add a Table.Column step. If the error mentions the page size, ensure it is a positive whole number. If the result looks wrong, expand the list to a table and inspect the chunks. For very large lists, List.Split is efficient, but converting the result to a table and expanding can be slow; consider filtering or aggregating before expanding. If the query fails after a Power Query update, check that your M code uses the correct function name and syntax; List.Split has been stable, but other functions may change.

Frequently Asked Questions

What does List.Split return?

It returns a list of lists. Each inner list contains up to the specified number of items from the original list, in order. The last inner list may have fewer items.

Can I split a list into chunks of unequal sizes?

No, List.Split uses a fixed page size. For unequal chunks, you need custom logic, such as splitting at specific indices using List.Range or List.FirstN and List.Skip in a loop.

Does List.Split work on text?

No, it works on lists. To split text into characters, use Text.ToList first. To split text by a delimiter, use Text.Split.

How do I remove empty chunks?

List.Split does not produce empty chunks unless the input list is empty. If you have empty lists in your source, filter them out with List.Select before splitting.

Is List.Split available in all Power Query versions?

Yes, it is a standard M function available in Excel and Power BI. The exact menu paths to open Power Query may vary by version.