Sub topic 3
Profiling data: column quality, distribution, and profile
This chapter assumes you can open Power BI Desktop, connect to a CSV or Excel file, and open the Power Query Editor. You should know what rows, columns, and data types are. You should also have seen the Applied Steps pane. Here you learn to inspect a table before you change it, so that each cleaning step targets a real problem.
Why profile before cleaning
Profiling means measuring what is in your data without changing it. The Power Query Editor shows these measures in the ribbon and under each column header. A typical dataset has nulls, errors, repeated rows, and values of the wrong type. If you clean without looking, you fix what you guess is wrong and miss the rest.
Profiling answers four questions:
- Which columns contain errors or empty values, and how many?
- How many distinct values does each column hold?
- Are any values unexpected, such as a negative quantity or a date in the year 1900?
- Is the column's data type the one you intended?
Profiling does not add steps to Applied Steps. Turning the tools on or off changes only what the editor displays.
The three profiling tools
The View tab in the ribbon has a Data Preview group with three check boxes: Column quality, Column distribution, and Column profile. The first two add small panels above the column headers. The third opens a larger pane below the table.
| Tool | Where it appears | What it shows | Best for |
|---|---|---|---|
| Column quality | Under each header | Percent Valid, Error, and Empty | Finding nulls and errors |
| Column distribution | Under each header | Bar chart of value frequency, plus Distinct and Unique counts | Spotting duplicates and key columns |
| Column profile | Pane below the table | Statistics and a value histogram for the selected column | Detailed inspection of one column |
Column quality
Column quality shows three percentages for each column:
- Valid is the share of values that are present and have no error.
- Error is the share of values that raised an error, usually from a failed type conversion.
- Empty is the share of values that are null or an empty string.
The three add up to 100 percent. A column with 2 percent Empty is a candidate for the null handling covered in a later chapter. A column with any Error percentage needs attention before you load the data, because errors can block a refresh or hide rows from results.
Hover over the quality bar to see the counts. Open the small menu that appears there to get shortcuts such as Remove Errors, Replace Errors, and Remove Empty. These shortcuts add steps to Applied Steps. Reading the percentages does not.
Column distribution
Column distribution draws a bar chart for each column. Each bar represents how often a value occurs. Two counts appear beneath the chart:
- Distinct is the number of different values, with each repeated value counted once.
- Unique is the number of values that appear exactly once.
Comparing these counts tells you a lot:
- If Distinct equals Unique, and both equal the row count, every value is different. This is what a key column such as
OrderIDshould look like. - If Distinct is much smaller than the row count, the column holds categories, such as a region or a status.
- If an
OrderIDcolumn shows Unique lower than the row count, some IDs repeat. That is a sign of duplicate rows.
Misspellings also show up here. A Region column with the values West, west, and West (with a trailing space) shows three distinct values where you expected one. This points you to the text cleaning chapter.
Column profile
Column profile gives a fuller view of one column at a time, the column you have selected. It opens a pane with two parts. On the left is a column statistics table. On the right is a value distribution histogram.
For a numeric column, the statistics include:
- Count, Error, Empty
- Distinct and Unique
- Min and Max
- Average and Standard Deviation
- Even and Odd counts, and Zero count
For a text column, you see the counts and the Min and Max in alphabetical order, but no averages. Min and Max are useful for sanity checks. If Amount has a Min of -50,000 and the business has no refunds, you have found bad data.
You can click a bar in the histogram, and a menu offers filters such as Equals and Does not equal. Pick one to add a filter step. You can also right-click a value in the histogram and copy it. Use this to check suspicious values quickly.
The row limit: a common mistake
By default, profiling reads only the first 1,000 rows of the data. The status bar at the bottom of the editor says "Column profiling based on top 1000 rows". A column can look perfectly clean in the first 1,000 rows and have errors at row 40,000.
To profile the whole table, click that text in the status bar and choose Column profiling based on entire data set. On large sources this can be slow, because the editor must read every row. If the query folds back to a database, the work happens at the source. If it does not, Power Query scans the data locally.
Decide which mode fits the task:
| Mode | Speed | Risk |
|---|---|---|
| Top 1,000 rows | Fast | Misses problems that occur later in the data |
| Entire data set | Slower on large sources | None for accuracy, but can delay each preview update |
A practical routine is to work in the default mode while you build steps, then switch to the entire data set once before you finish and check Column quality again.
A profiling workflow
The following order works for most new tables:
- Turn on all three tools in View > Data Preview.
- Switch to Column profiling based on entire data set.
- Scan Column quality for any non-zero Error or Empty percentage.
- Scan Column distribution for key columns that are not unique and categories with too many distinct values.
- Select each suspicious column and read its Column profile for Min, Max, and the histogram.
- Write down the problems you found, then fix them in a deliberate order.
The order of fixing matters. Set data types before you judge errors, because a type change is what creates conversion errors. Profile again after each major step to confirm that the problem is gone.
Reading the data type icon
Each header also carries a small icon that shows the column's data type, such as 123 for whole numbers or ABC for text. The icon ABC123 means the type is Any, meaning no type is set. Profiling a column of type Any can mislead you. Dates, numbers, and text look alike until a type is applied, so statistics such as Min and Max may be missing. Setting types comes in a later chapter, but note the icons while you profile.
Profiling in the M code
Profiling itself leaves no trace in the M code. However, M has functions that return the same kind of statistics. Table.Profile returns a table with one row per column and fields such as Min, Max, Count, NullCount, and DistinctCount. The following query builds a small table and profiles it:
let
Source = #table(
type table [OrderID = Int64.Type, Region = text, Amount = number],
{
{1, "West", 120},
{2, "East", null},
{3, "West", 90},
{3, "west ", -50}
}
),
Profile = Table.Profile(Source)
in
ProfileThe result has four rows, one for each column's statistics. Look at the DistinctCount and NullCount columns. OrderID has a count of 4 but only 3 distinct values, which matches the repeated ID 3. Region shows 3 distinct values because of the case and spacing differences. Amount has one null, and its minimum is -50. These are the same facts the three tools show visually. Use Table.Profile when you want profiling output in a table that you can filter, or when you want to keep it in a separate query.
Edge cases
- Empty strings versus null. Both count as Empty in Column quality, but they are different values in M. A filter for null will not match an empty string. Replace empty strings with null first if you want one rule.
- Error rows hide in statistics. Min, Max, and Average ignore error cells. A column with 30 percent Error can still show a neat Average.
- Filtered rows change the profile. Profiling reflects the current step. If you select an earlier step in Applied Steps, the profile shows the data as it was then. This is a useful way to see what a step changed.
- Wide tables. Column profile works on the selected column only, so for a table with 100 columns, start from Column quality and open the profile only for flagged columns.
Exercise
A column CustomerID shows 10,000 rows in the entire-data-set mode, with Distinct = 9,200 and Unique = 8,500. What does this tell you, and which tool confirms the details for one value?
Show answer
Some IDs repeat. Distinct is below the row count, so at least 800 IDs appear more than once, and Unique below Distinct means some values appear two or more times. If CustomerID is meant to be a key, this suggests duplicate rows or a bad join. Select the column and open Column profile to see the histogram and statistics. Click a tall bar in the value distribution to filter to the repeated value and inspect its rows.
Exercise
Your query looks clean in the editor, with 0% Error in every column, but the refresh after Close & Apply fails with a conversion error. What is the most likely cause and the fix?
Show answer
Profiling used only the first 1,000 rows, so errors further down were not counted. Switch the status bar to "Column profiling based on entire data set", check Column quality again, and then fix the errors with Replace Errors or Remove Errors, or correct the data type or locale.