Count Non-Blank Cells Across Columns in Excel Power Query
Question details
Find a Power Query M equivalent of Excel's COUNTA function for counting non-empty values across multiple columns.

- Product
- Microsoft Excel Power Query
- Device & OS
- not provided
- Scenario
- Add a count for each row across selected columns in a Power Query table.
- Observed behavior
- The desired result is a per-row count of populated values, with a choice of whether to include empty text strings.
Open the query in Power Query Editor and check the exact names of the columns you want to count. Decide whether empty text strings should count as values or be excluded along with nulls.
Count non-null values with List.NonNullCount
Use this method to count non-null values across specified columns in each row.
In Excel, select Data > Queries & Connections, then double-click the query to open Power Query Editor.
In Power Query Editor, select Add Column > Custom Column and enter a name such as Non-null count.
In the Custom column formula box, enter `List.NonNullCount({[A], [B], [C], [D], [E], [F], [G], [H], [I], [J]})`. Replace A through J with your actual column names, then select OK.
Check the counts in the new column, then select Home > Close & Load to return the results to Excel.

Exclude nulls and empty strings from the count
Use this variation when both null values and empty text strings should be treated as blank.
Count populated cells in WPS Spreadsheets
WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and Excel format compatibility for an easy transition. Use COUNTA in WPS Spreadsheets to count populated cells in a worksheet; it does not replace the Power Query M solution.

Frequently Asked Questions
What is the Power Query equivalent of COUNTA across columns?
In Add Column > Custom Column, use `List.NonNullCount({[A], [B], [C]})` and replace the column names with yours. It counts values that are not null, including empty text strings.
How do I exclude empty strings as well as nulls?
Use `List.Count(List.Select({[A], [B], [C]}, each _ <> null and _ <> ""))` in a custom column. This excludes both null and empty text values.
Will zeros and false values be counted?
Yes. Both formulas count zero and false because neither is null or an empty text string.
Can I count populated cells without Power Query?
In an Excel or WPS Spreadsheets worksheet, enter `=COUNTA(A2:J2)` in a cell to count non-empty cells across that row. COUNTA includes cells containing formulas that return an empty string.




