New Tool Radar

AI for Data & Spreadsheets

How to Promote Headers and Set Data Types First in a Power Query Clean-Up

In Power Query, promote the first row to headers and set each column data type before any other cleaning step.

Schematic with three steps: Load the data into the Power Query; Promote the first row to headers; Set the data type of each column.

Power Query records every click as a step, and later steps refer to columns by name and type. Promoting headers and setting types first means every step after it works on named, correctly typed columns instead of Column1 and guessed types.

What you need

  • Excel with Power Query, and a CSV or table to clean
  • A note of what each column should be: date, number or text
  • A copy of the source file

Step 1: Load the data into the Power Query Editor

Use Data, Get Data, From File, From Text/CSV, pick the file and click Transform Data to open the Power Query Editor. If the file starts with a title row, remove the top rows first with Home, Remove Rows, Remove Top Rows.

Step 2: Promote the first row to headers

Choose Home, Use First Row as Headers so the real field names become column names. If the preview shows Column1 and Column2, the headers have not been promoted yet.

Step 3: Set the data type of each column

Select each column and set its type from the icon in the header: Date for dates, Whole Number or Decimal Number for amounts, Text for IDs. Getting types right early avoids errors in every later step.

Worked example: synthetic 100-row CSV import

The table below is a synthetic example. It shows the expected result of promoting headers and setting types; no file was imported.

Check Count Result
Rows loaded 100 Source
Headers promoted 5 All columns named
Date column set to Date 100 Pass
Amount column set to Decimal 98 2 errors flagged

Expected result (UNTESTED). all 5 headers are promoted, the date column is typed as Date, and the amount column is typed as Decimal with 2 rows flagged as errors for review. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • Power Query may guess column types from the first 200 rows; check the guess before loading.
  • Set types before trimming or splitting, because many transforms depend on the type.
  • Removing a step that later steps depend on will break the query; rename steps instead.

Sources

See all