Skip to content

Load data into Power Query and set column types

Power Query basics9 minPremium

Builds on Why Power Query: record a cleanup once, repeat it every month and Import a CSV file without losing zeros and dates.

A store operations manager in Phoenix gets the daily sales file from the point-of-sale system. In the Power Query Editor its columns are called Column1, Column2 and Column3, every value is text, and the store numbers have to keep their leading zeros.

How it works

A text file carries no column types, and nothing in it marks the first line as headings. Power Query may show the headings as the first row of data and every column as text, or guess both itself: for text and CSV files it checks the first 200 rows and adds Promoted Headers and Changed Type steps. Three commands put the table right:

  • Home > Remove Rows > Remove Top Rows takes out lines above the headings, such as a title.
  • Home > Use First Row as Headers turns the first row into the column names.
  • The icon at the left of each heading shows the column's type. Click it to pick another, or use Transform > Data Type.
RowABC
1IconTypeFor
2ABCTextNames, and codes such as 0042, even when they hold only digits
3123Whole NumberCounts
41.2Decimal NumberAmounts and measurements
5A calendarDateDates
6ABC123AnyNothing set yet

A value the type can't read shows as Error in the preview, so look down a column after you change its type. For dates written day first, choose Using Locale on the icon's menu and pick the file's country.

Home > Close & Load writes the result to a new sheet as a table. Close & Load To offers other places, such as a PivotTable report, or Only Create Connection for a query that other queries use.

Example

A supplier's price list before and after the two steps:

Use First Row as Headers moves the first row into the headings, and each type turns the text into what the column holds. SKU stays Text, so its zeros survive.

Common mistakes

  • A code column left as Whole Number. Power Query's own guess, or your click, turns 0042 into 42. Set it to Text.
  • Use First Row as Headers while a title still sits on top. The title becomes a heading. Remove the top rows first.
  • Decimal Number for a column with a stray word, such as n/a. Those cells show Error, so replace the word first.

In short

  • Remove Top Rows, then Use First Row as Headers, puts the headings where they belong.
  • Each column's icon shows its type: Text for codes, Whole Number for counts, Decimal Number for amounts, Date for dates.
  • Close & Load writes the result to a new sheet.

Practice

Premium

4 exercises: 3 queries and 1 quiz question.

Practice is part of Premium

Every lesson is free to read, and you can practice the free lessons without an account. This lesson's exercises are part of Premium, which you add to a free account.