Smart Systems for Home

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

Power Query List.Single: How to Extract One Value

· 6 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.Single takes a list and returns its only item; if the list contains zero or more than one item, it throws an error. You use it when a query step should produce exactly one value, and you want the query to fail loudly instead of silently picking the first item. No add-in or special setup is needed: List.Single is a built-in Power Query M function available in Excel, Power BI Desktop, and Power BI Service dataflows. You do need a list to pass to it, which usually means first filtering or selecting a column and then converting that column to a list.

What You'll Need

  • Excel with Power Query (Data > Get Data), Power BI Desktop, or a Power BI dataflow.
  • A query that already loads the table or list you want to inspect.
  • A basic understanding of the Power Query Editor and the formula bar.

Step-by-Step

  1. Open Power Query Editor: in Excel go to Data > Get Data > Launch Power Query Editor; in Power BI Desktop go to Home > Transform data. Menu labels can differ slightly by version, device, and region.
  2. Load or select the query that contains the list you want to reduce to a single value. If you are starting from a table, make sure the column you care about is visible.
  3. Turn the column into a list. Right-click the column header and choose Drill Down, or use the formula bar to reference the column as a list, for example Source[ColumnName]. A drill-down creates a query step whose result is a list rather than a table.
  4. Add a custom step that calls List.Single. Open the Advanced Editor (Home > Advanced Editor) or add a step in the formula bar, and write something like List.Single(Source[ColumnName]). If you are editing an existing step, replace the list reference with the List.Single call.
  5. Confirm the list has exactly one item. If the step returns a value, the list contained one item. If it returns an error, the list contained zero or multiple items; see Troubleshooting below.
  6. Optionally provide a default for the empty case. List.Single has an optional second argument: List.Single(list, default). If the list is empty, the default is returned instead of an error. The default does not help when the list has more than one item; that still errors.
  7. Use the result. Once the step returns a single value, you can reference that step elsewhere, merge it into another query, or load it as a scalar value. If you need the value inside a table, wrap it in a one-row table or use it in a calculated column.
  8. Close and load when the query returns the expected value. In Excel choose Home > Close & Load; in Power BI choose Home > Close & Apply.

Common Mistakes

  • Passing a table instead of a list. List.Single expects a list; a one-column table will not work. Convert the column to a list first, for example with a drill-down or by referencing the column directly.
  • Assuming List.Single picks the first item. It does not; it requires exactly one item and errors otherwise. Use List.First if you actually want the first item.
  • Forgetting that filters can leave zero rows. A filter that matches nothing produces an empty list, and List.Single then errors unless you supply a default.
  • Using the optional default to hide duplicate data. If the list has two or more items, List.Single still errors; the default only covers the empty case.
  • Expecting the step to show a preview table. A list step previews as a list, not a table; that is normal.

Tips

  • Use List.Single as a guard: it is a good way to make a query fail when a lookup that should return one row returns none or several.
  • Pair it with List.Count to diagnose problems: List.Count(Source[ColumnName]) tells you how many items the list actually has before you call List.Single.
  • If you need the single value in a table context, consider Table.SingleRow or Table.FirstValue on a one-row table instead, depending on whether you want a record or a scalar.
  • Keep the list reference simple. Referencing a column directly, such as Source[ColumnName], is easier to debug than building the list through several intermediate steps.
  • Name your steps clearly so the error message points to an understandable place in the query.

Troubleshooting

If List.Single returns an error, first check how many items the list contains. Add a temporary step with List.Count on the same list and look at the result. If the count is 0, the list is empty: either adjust the filter that produced it or supply a default as the second argument. If the count is greater than 1, the list has duplicates or multiple matching rows: add or tighten a filter so only one item remains, or use a different function such as List.First or List.Max if any single item is acceptable.

If the error says the argument is not a list, check that you are referencing a column as a list and not a table. In the formula bar, a column reference like Source[ColumnName] produces a list; a step that returns a table needs to be drilled down first. If the query step itself is not updating, close the Advanced Editor without saving, re-open it, and confirm the step name and syntax. If the issue persists, restart the application and reopen the file; for Power BI, also check that the query has no pending changes that conflict with the step you edited.

If the result looks correct in the editor but wrong after loading, check whether the query is folding or being evaluated in a different context. A scalar step loaded to a worksheet appears in a single cell; in Power BI it appears as a value you can reference, not as a table. If you expected a table, wrap the value appropriately.

Frequently Asked Questions

What does List.Single do in Power Query?

It returns the only item in a list. If the list is empty or has more than one item, it returns an error unless you provide a default for the empty case.

Does List.Single return the first item?

No. It requires exactly one item. To get the first item regardless of list size, use List.First.

Can I avoid the error when the list is empty?

Yes, with the optional second argument: List.Single(list, default). The default is returned only when the list is empty; a list with multiple items still errors.

Why does List.Single work on a column but not a table?

List.Single expects a list. A column reference such as Source[ColumnName] is a list; a table is not. Drill down to the column or reference it directly.

How do I check how many items a list has before calling List.Single?

Use List.Count(list) in a temporary step. A count of 1 means List.Single will succeed; 0 or more than 1 will produce an error.

Is List.Single available in Excel and Power BI?

Yes, it is a standard Power Query M function available in Excel, Power BI Desktop, and Power BI dataflows. Menu labels for opening the editor can differ slightly by version and platform.