Table.Profile Function in Power Query M

Sumit Bansal
Written by

Sumit Bansal is the founder of TrumpExcel.com and a 13-time Microsoft Excel MVP. He started this site in 2013 to share his passion for Excel through easy tutorials, tips, and training videos, helping you master Excel, boost productivity, and maybe even enjoy spreadsheets!

The Table.Profile function in Power Query gives you a quick summary of every column in a table. In one step, you get each column’s minimum, maximum, average, standard deviation, count, null count, and distinct count.

It’s a fast way to check a dataset before you start working with it. This article shows how to use it to find missing values, spot duplicate IDs, and add statistics like the median.

There’s also one catch to know about. If your columns don’t have a data type, most of the statistics come back empty, and Example 2 shows what that looks like and how to fix it.

Follow along with the example file

Table.Profile Function Examples.xlsx

Download

Table.Profile Function Syntax

Table.Profile(table as table, optional additionalAggregates as nullable list) as table
  • table – the table you want to profile.
  • additionalAggregates (optional) – a list of extra statistics to add as new columns. Each item is a list of three things: the name of the new column, a function that decides which columns get the statistic, and a function that calculates it (Examples 7 and 8 show how).

What it returns: A table with one row for each column of your table. It has the columns Column, Min, Max, Average, StandardDeviation, Count, NullCount, and DistinctCount, and a statistic that doesn’t apply to a column (like the average of a text column) shows null.

The Table.Profile function is part of the Power Query M language, so you can use it in Power Query in Excel for Microsoft 365 and in Power BI.

When to Use the Table.Profile Function

Use this function when you need to:

  • Get a quick overview of a new dataset before you clean it
  • Find which columns have missing (null) values
  • Check whether an ID column has duplicate values
  • See the lowest and highest value or date in every column at once
  • Build a simple data quality report you can load to a sheet
  • Add your own statistics, like the median, for every number column

Example 1: Get a Quick Profile of Every Column

Let’s start with the basic use. Below is a table named CourseSignups with the students who signed up for an online course, and I want a summary of every column in it.

CourseSignups table with each student's course, fee, sign-up date and lessons done

In the code below, the Source line uses the Excel.CurrentWorkbook function to pull the CourseSignups table into Power Query by its name.

If you try this on your own data, format it as a table (Ctrl + T) and put your table’s name in place of “CourseSignups”.

In Excel, go to Data > Get Data > From Other Sources > Blank Query. In the Power Query Editor that opens, go to Home > Advanced Editor and use this code:

let
Source = Excel.CurrentWorkbook(){[Name="CourseSignups"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Student",type text},{"Course",type text},{"Fee",type number},{"Signed Up",type date},{"Lessons Done",Int64.Type}}),
Profile = Table.Profile(#"Changed Type")
in
Profile

Result: A table with one row for each column (Course, Fee, Lessons Done, Signed Up, and Student) and its statistics

Table.Profile returns one row for each column with its Min, Max, Average, StandardDeviation, Count, NullCount and DistinctCount

Here, the Changed Type step uses the Table.TransformColumnTypes function to give each column a data type (text, number, date, or whole number). Table.Profile then summarizes all five columns in one go.

Notice that the rows are in alphabetical order of the column names, not in the order the columns appear in the table.

In the Fee row, the lowest fee is 60, the highest is 120, and the average is 90.

Count is 6 (six rows), NullCount is 0 (no empty cells), and DistinctCount is 3, because there are only three different fees.

The Fee row’s StandardDeviation (about 26.83) is the sample standard deviation, the same thing Excel’s STDEV.S function calculates.

For a text column like Student, Min and Max give you the first and last value in alphabetical order (Lucy and Wayne). An average doesn’t make sense for text, so Average and StandardDeviation show null.

For the Signed Up date column, Min and Max give you the earliest and latest dates (1/5/2026 and 1/24/2026, that’s January 5 and January 24). Average gives you the average date, 1/14/2026, while StandardDeviation shows null for a date column.

In the example file, every example’s query is in Data > Queries & Connections. Double-click one to open it in the Power Query Editor.

Example 2: What You Get When Columns Have No Data Type

This next one shows the catch I mentioned at the start. Below is a table named VendorInvoices with invoice amounts and due dates, and I want to profile it straight from the source, without setting the data types.

VendorInvoices table with invoice amounts and due dates, one due date missing

Create a new blank query (as in Example 1), open the Advanced Editor, and use this code:

let
Source = Excel.CurrentWorkbook(){[Name="VendorInvoices"]}[Content],
Profile = Table.Profile(Source)
in
Profile

Result: Only the Count and NullCount columns have values. Min, Max, Average, StandardDeviation, and DistinctCount are null for every column

Without data types, only Count and NullCount have values and the other statistics are null

Here, Table.Profile still counts the rows (6) and the null values (1, for the empty Due Date of Cedar Office Co.). But all the other statistics come back null, even for the Invoice Amount column, which is clearly full of numbers.

That’s because the Excel.CurrentWorkbook function brings every column in with the type any (the ABC123 icon in the column header). Table.Profile doesn’t calculate the minimum, maximum, average, standard deviation, or distinct count for a column with no data type.

Important: If Table.Profile shows null in the Min, Max, and Average columns for every column, your columns don’t have a data type. Set the types first (a Changed Type step like in Example 1), then profile the table.

To set the types without writing code, do it before the Profile step. Click the Source step in Applied Steps, select the columns, and pick a type from Transform > Data Type.

Power Query asks whether to insert a new step. Click Insert, and it adds a Changed Type step before Profile.

Example 3: Find Columns That Have Missing Values

Here’s one of the most useful things you can do with a profile. Below is a table named SignupForm with responses from a sign-up form, and I want a list of only the columns that have missing values.

SignupForm table with some missing phone numbers and cities

Create a new blank query, open the Advanced Editor, and use this code:

let
Source = Excel.CurrentWorkbook(){[Name="SignupForm"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Name",type text},{"Email",type text},{"Phone",type text},{"City",type text},{"Age",Int64.Type}}),
Profile = Table.Profile(#"Changed Type"),
#"Columns With Blanks" = Table.SelectRows(Table.Buffer(Profile),each [NullCount]>0)
in
#"Columns With Blanks"

Result: Two rows, City (NullCount 1) and Phone (NullCount 2)

Filtering the buffered profile on NullCount keeps only the City and Phone rows

Here, the Profile step profiles all five columns. The last step then uses the Table.SelectRows function to keep only the rows where NullCount is more than 0, so Name, Email, and Age drop out because they have no empty cells.

You might wonder why the profile is wrapped in the Table.Buffer function. Without it, Table.SelectRows(Profile,each [NullCount]>0) gives the error Expression.Error: The field ‘NullCount’ of the record wasn’t found, even though the NullCount column is right there.

Important: To filter a profile on any statistic (NullCount, Count, DistinctCount, Average, and so on), wrap it in the Table.Buffer function first. It loads the profile into memory, and the filter then works as expected.

Filtering on the Column column (the column names) works without the Table.Buffer function, and so does sorting the profile. It’s only the statistic columns that need it.

Also note that NullCount only counts null values. A cell that holds an empty text or a space isn’t null, so it won’t show up here (Example 8 shows how to catch those).

Example 4: Calculate the Percentage of Missing Values in Each Column

Now let’s turn the profile into a small data quality report. Below is a table named StaffDirectory with employee details, and I want the number and percentage of missing values in each column.

StaffDirectory table with some missing offices, start dates and desk extensions

Create a new blank query, open the Advanced Editor, and use this code:

let
Source = Excel.CurrentWorkbook(){[Name="StaffDirectory"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Employee",type text},{"Department",type text},{"Office",type text},{"Start Date",type date},{"Desk Ext",Int64.Type}}),
Profile = Table.Profile(#"Changed Type"),
#"Kept Columns" = Table.SelectColumns(Profile,{"Column","Count","NullCount"}),
#"Added Missing %" = Table.AddColumn(#"Kept Columns","Missing %",each [NullCount]/[Count],Percentage.Type)
in
#"Added Missing %"

Result: A table with Column, Count, NullCount, and Missing % (37.50% for Desk Ext, 25.00% for Office, 12.50% for Start Date, and 0.00% for the rest)

A Missing % column shows the share of empty cells in each column

Here, the Table.SelectColumns function keeps just the three columns we need from the profile. Then the Table.AddColumn function adds a Missing % column that divides NullCount by Count.

This works because Count is the total number of rows, including the empty ones. So Desk Ext, with 3 empty cells out of 8 rows, is 3/8, or 37.50% missing.

The Percentage.Type at the end of the Table.AddColumn step makes the new column show as a percentage instead of a decimal like 0.375.

Follow along with the example file

Table.Profile Function Examples.xlsx

Download

Example 5: Check Which Columns Have All Unique Values

This one is handy when you need a column you can use as an ID. Below is a table named Shipments with one row per package, and I want to check which columns have a different value in every row.

Shipments table with one row per package

Create a new blank query, open the Advanced Editor, and use this code:

let
Source = Excel.CurrentWorkbook(){[Name="Shipments"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Tracking No",type text},{"Order No",type text},{"Carrier",type text},{"Weight (kg)",type number}}),
Profile = Table.Profile(#"Changed Type"),
#"Kept Columns" = Table.SelectColumns(Profile,{"Column","Count","DistinctCount"}),
#"Added Unique Check" = Table.AddColumn(#"Kept Columns","All Unique",each [DistinctCount]=[Count],type logical)
in
#"Added Unique Check"

Result: A table with Column, Count, DistinctCount, and All Unique (TRUE only for Tracking No)

The All Unique column is TRUE only for Tracking No

Here, DistinctCount is the number of different values in a column. If no value repeats, it equals Count (the number of rows), and the All Unique column shows TRUE.

Tracking No has 8 different values in 8 rows, so it’s TRUE. Order No has only 6, because orders ORD-1042 and ORD-1046 were each shipped in two packages, so it’s FALSE.

So in this table, Tracking No is the column you can use as an ID, and Order No isn’t.

One thing to watch for is that DistinctCount counts null as a value of its own, and Count includes the empty cells.

So a column with one empty cell and all other values different still shows TRUE. If your ID column could have blanks, check its NullCount too.

Example 6: Profile Only the Number Columns

Sometimes you only care about the numbers. Below is a table named DeliveryLog with each driver’s stops, miles, and fuel cost, and I want statistics for the number columns only.

DeliveryLog table with each driver's stops, miles and fuel cost

Create a new blank query, open the Advanced Editor, and use this code:

let
Source = Excel.CurrentWorkbook(){[Name="DeliveryLog"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Driver",type text},{"Zone",type text},{"Stops",Int64.Type},{"Miles",type number},{"Fuel Cost",type number}}),
#"Number Columns" = Table.SelectColumns(#"Changed Type",Table.ColumnsOfType(#"Changed Type",{type nullable number})),
Profile = Table.Profile(#"Number Columns")
in
Profile

Result: A profile with three rows, for Fuel Cost, Miles, and Stops

The profile covers only the Fuel Cost, Miles and Stops number columns

Here, the Table.ColumnsOfType function returns the names of all the columns whose type is a number. The Table.SelectColumns function keeps only those columns, and Table.Profile then profiles them.

The Driver and Zone text columns are left out, so you don’t get rows full of nulls for them. The average driver made 20 stops, drove 70 miles, and spent 24 on fuel.

The type in the formula is type nullable number (a number that can also be empty), and it picks up whole number columns like Stops as well.

Since the code finds the number columns by their type, you never have to list them in the Table.SelectColumns step. If you add a number column later, give it a number type in the Changed Type step, and it’s picked up automatically.

Example 7: Add a Median Column with additionalAggregates

Now let’s use the optional second argument. Below is a table named ApartmentRents with the rent and size of seven apartments, and I want to add the median to the profile, because one expensive apartment pulls the average up.

ApartmentRents table with the rent and size of seven apartments

Create a new blank query, open the Advanced Editor, and use this code:

let
Source = Excel.CurrentWorkbook(){[Name="ApartmentRents"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Unit",type text},{"Neighborhood",type text},{"Monthly Rent",type number},{"Square Feet",Int64.Type}}),
Profile = Table.Profile(#"Changed Type",{{"Median",each Type.Is(_,type nullable number),List.Median}})
in
Profile

Result: The usual profile with an extra Median column (1520 for Monthly Rent, 760 for Square Feet, and null for the two text columns)

An extra Median column shows 1520 for Monthly Rent and 760 for Square Feet

Here, the second argument is a list with one item, {"Median",each Type.Is(_,type nullable number),List.Median}. It has three parts.

The first part, “Median”, is the name of the new column.

The second part is a test that decides which columns get the statistic. It receives each column’s data type as _, so Type.Is(_,type nullable number) is true only for the number columns.

The third part is the function that calculates the statistic. Power Query passes it all the values of the column as a list, and the List.Median function returns the middle value.

Unit and Neighborhood are text, so they fail the test and get null in the Median column.

The median rent is 1520, while the average is about 1884. That gap comes from the Lakefront apartment at 4200, which pulls the average up but barely moves the median.

Important: Use type nullable number in the test, not type number. After a Changed Type step, columns can hold nulls, so Type.Is(_,type number) is false for every column and the Median column comes back all null.

To add more than one statistic, put more three-part lists inside the outer list, separated by commas.

Example 8: Count Cells That Look Blank but Aren’t Null

Here’s a problem you’ll hit with data exported from other systems. Below is a table named CustomerContacts where some cells look empty, and I want to count all the blank-looking cells in each text column.

CustomerContacts table where some cells look empty

Only one of these cells, Dominic’s phone, is really empty, so Power Query shows it as null. The others (Darren’s company, Edward’s and Evelyn’s phones, and Audrey’s city) hold a single space, which you can’t see.

Create a new blank query, open the Advanced Editor, and use this code:

let
Source = Excel.CurrentWorkbook(){[Name="CustomerContacts"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Customer",type text},{"Company",type text},{"Phone",type text},{"City",type text},{"Orders",Int64.Type}}),
Profile = Table.Profile(#"Changed Type",{{"Blank Cells",each Type.Is(_,type nullable text),each List.Count(List.Select(_,each _=null or Text.Trim(_)=""))}})
in
Profile

Result: The usual profile with an extra Blank Cells column (3 for Phone, 1 for Company, 1 for City, 0 for Customer, and null for Orders)

The Blank Cells column counts empty and space-only cells in each text column

In the Phone row, NullCount is just 1, because only the empty cell counts as null. The two cells with a space are text, so the built-in NullCount misses them.

The Blank Cells column fixes that. For each text column, the List.Select function keeps the values that are null, or that are empty after the Text.Trim function removes the spaces, and the List.Count function counts them.

That gives 3 for Phone (one empty cell and two spaces), and 1 each for Company and City. The Orders column is a number, so it fails the type nullable text test and gets null.

There are two each keywords in this formula. The outer _ is the list of values in a column, and the inner _ is one value from that list.

You’ll also notice that Min looks empty for Phone, Company, and City. That’s the space, which comes before any letter or digit when the values are sorted.

Other Excel Articles You May Also Like:

  • Table.ToRows function
  • Table.Schema – Use Table.Schema in Power Query M to see each column’s name, position, and type.
  • List.NonNullCount – Use List.NonNullCount in Power Query M to count the filled, non-null values in a list.
  • Table.RowCount – Use Table.RowCount in Power Query M to count table rows.
  • Table.ColumnNames – Use Table.ColumnNames in Power Query M to list a table’s column names.
  • List.Average – Use List.Average in Power Query M to average a list.
  • Table.Distinct – Use Table.Distinct in Power Query M to remove duplicate rows.
  • List.RemoveNulls – Use List.RemoveNulls in Power Query M to drop null values from a list.

All Power Query Functions

Sumit Bansal

Sumit Bansal

13x Microsoft Excel MVP

Hey! I'm Sumit Bansal, founder of trumpexcel.com and a Microsoft Excel MVP. I started this site in 2013 because I genuinely love Microsoft Excel (yes, really!) and wanted to share that passion through easy Excel tutorials, tips, and Excel training videos. My goal is straightforward: help you master Excel skills so you can work smarter, boost productivity, and maybe even enjoy spreadsheets along the way!

Get the FREE 51 Excel Tips Ebook

Enter your details and the free PDF is on its way to your inbox.

Hmm, that didn't go through. Please check your email and try again.

No spam. You'll also get my weekly Excel newsletter. Unsubscribe anytime.

Check your inbox!

The ebook is on its way to your email. It usually lands within a couple of minutes.