Smart Systems for Home

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

Power Query List.IsDistinct Function 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

The List.IsDistinct function in Power Query checks whether all values in a list are unique, returning TRUE if they are and FALSE if any duplicates exist. No setup or prerequisites are required beyond having Power Query available in Excel or Power BI.

What You'll Need

  • Microsoft Excel (2016 or later) with Power Query enabled, or Power BI Desktop
  • A data table or custom list to test against
  • Basic familiarity with Power Query Editor

Step-by-Step

  1. Open Excel or Power BI Desktop and load your data into Power Query. In Excel, go to the Data tab > Get Data > From Other Sources > From Table/Range (or From Table if your data is already formatted as a table). In Power BI, use Get Data > Select your source > Transform Data to open the Power Query Editor.
  2. In the Power Query Editor, locate the column or create a custom column where you want to evaluate uniqueness. If you're testing a specific list (e.g., a list of IDs or names), right-click the column header and choose Enter Data to open a blank query, then paste or type your list items into the first column.
  3. With your table open, go to the Add Column tab > Custom Column. In the dialog box, name the new column something descriptive like "IsUnique" or "AllDistinct".
  4. In the Custom column formula box, enter the formula: List.IsDistinct(YourColumn). Replace "YourColumn" with the actual column name—use square brackets, e.g., List.IsDistinct(#"Changed Type"[ID]). Ensure the column reference matches the exact name shown in the Applied Steps pane.
  5. Click OK. Power Query evaluates each row's list (or the column as a whole, depending on context) and populates the new column with TRUE or FALSE values. Note: List.IsDistinct operates on a single list argument, so for a table column, it checks all values in that column *as one combined list*, not row-by-row. To check uniqueness per row, you must first group or transform data appropriately (see Tips).
  6. To test the function directly in the formula bar, open a new blank query (Home > New Source > Blank Query), then in the formula bar, type: = List.IsDistinct({1, 2, 3, 2}) and press Enter. The result will be FALSE because the list contains duplicate "2". Try = List.IsDistinct({"A", "B", "C"}) for TRUE.
  7. Once verified, close & load the query back to Excel or Power BI to use the new column in reports or exports.

Common Mistakes

  • Using List.IsDistinct on a table instead of a list—e.g., passing a table reference like MyTable—will cause an error. Always pass a list: use Table.Column(MyTable, "ColumnName") to extract the column as a list first.
  • Incorrect column name casing or spacing—Power Query is case-sensitive and sensitive to spaces. Match the exact name shown in the Applied Steps pane (e.g., "#"Changed Type"[ID]" not "Changed Type[Id]").
  • Assuming row-level evaluation: List.IsDistinct evaluates *all* values in the column as one list. If you need to flag duplicates per row (e.g., in a grouped dataset), you must group first (Home > Group By), then apply List.IsDistinct to the grouped list.
  • Confusing List.IsDistinct with Table.Distinct: List.IsDistinct returns TRUE/FALSE; Table.Distinct removes duplicate rows and returns a table. They serve different purposes.

Tips

  • Combine with List.Transform for batch validation: Table.AddColumn(MyTable, "UniqueCheck", each List.IsDistinct({[Col1], [Col2], [Col3]})) checks uniqueness across multiple columns *per row*.
  • Use in conditional logic: if List.IsDistinct(#"Sorted Rows"[ProductID]) then "All IDs Unique" else "Duplicates Found" for dynamic messaging.
  • Debug by inserting a List.Count step: compare List.Count(yourList) with List.Count(List.Distinct(yourList)). If they differ, duplicates exist.
  • For large datasets, avoid List.IsDistinct in row-by-row contexts—it can slow performance. Instead, use Table.Distinct to extract duplicates, then merge back.
  • Handle nulls: List.IsDistinct treats null as a value. {null, null} returns FALSE, while {1, null, 2} returns TRUE.

Troubleshooting

  • Error: "Expression.Error: We cannot apply operator < to types Text and Number." This occurs if your list mixes data types. Convert all values to text first: List.Transform(yourList, each Text.From(_)), then wrap in List.IsDistinct.
  • Unexpected TRUE with duplicates present: Verify the list source. If using a column reference, ensure no filtering or row selection is active (e.g., a filtered table might only contain unique values). Check the Applied Steps pane for hidden filters.
  • Blank or false results with no error: Confirm the column isn’t empty. An empty list returns TRUE. Test with = List.IsEmpty(yourList) first.
  • Formula bar syntax not accepted: When typing directly in the formula bar, omit quotes around column names. Use [ColumnName] only in custom column editors, not in the main formula bar. In the formula bar, use explicit list syntax like {1, 2, 3}.
  • Performance lag: For tables with >10,000 rows, avoid List.IsDistinct in custom columns. Instead, create a separate query to check uniqueness once, then merge (Home > Merge Queries).

Frequently Asked Questions

Does List.IsDistinct work with case-sensitive text?

Yes—"Apple" and "apple" are treated as different values. For case-insensitive checks, convert first: List.IsDistinct(List.Transform(list, each Text.Upper(_))).

Can I use List.IsDistinct to find duplicates in a table?

Not directly. It returns TRUE/FALSE for the *entire column*. To list duplicate rows, use Table.Distinct to get unique rows, then compare row counts, or use Group By with Count to identify duplicates.

Why does List.IsDistinct return TRUE for a list with nulls?

Only if there’s a single null or no nulls. {null} returns TRUE; {null, null} returns FALSE. Two or more nulls are considered duplicates.

Does List.IsDistinct handle decimals or floating-point precision issues?

Yes—it compares exact values. 1.0000000001 and 1.0000000002 are distinct, but rounding errors (e.g., 0.1 + 0.2 ≠ 0.3) can cause unexpected results. Use Number.Round to normalize decimals before checking.

Is there a limit to how many items List.IsDistinct can process?

Power Query handles lists up to ~2 billion items, but performance degrades with very large lists (>100,000 items). For large datasets, prefer native deduplication tools like Remove Duplicates in Excel or Table.Distinct in Power Query.

Can List.IsDistinct be used in Power BI DAX?

No—List.IsDistinct is a Power Query (M language) function. In DAX, use DISTINCT() or COUNTROWS(DISTINCT(table[column])) for similar checks.