Split columns and set data types

Two pieces of information in one column, numbers stored as text, ZIP codes without their leading zero: these are the most common reasons a report calculates wrongly. Here you learn to split columns and give every field the right data type.

In short: Split Column, By Delimiter turns "Hardware|Laptop" into two columns. Under Data Type you choose Whole Number, Decimal Number, Text or Date. Power BI can only sum numbers; codes such as ZIP codes stay text.

Prerequisites: Clean data.

Try it now

Task The Item column holds category and product together, separated by a vertical bar (|). Split the column at | so that category and product end up in two columns.

ABC
1 Item Qty Price
2 Hardware|Laptop 3 899
3 Hardware|Monitor 5 229
4 Accessories|Mouse 12 19.9
5 Software|Office suite 2 149
6 Accessories|Keyboard 7 39.9

Split a column

Under Home or Transform you find Split Column with several options. The most common is By Delimiter: comma, semicolon, space, hyphen or a character of your own. Power Query creates as many new columns as it finds parts and names them Item.1, Item.2 and so on. Rename them by double-clicking the header.

Other options are By Number of Characters (fixed widths from old systems) and By Positions. For irregular patterns there is Column From Examples under Add Column: you type two or three results and Power Query works out the rule.

Data types

Data typeForWatch out
Whole Numberquantities, countsrounds decimals
Decimal Numberamounts, prices, weightsfloating point, usually fine for money
Fixed decimal numbermoneyfour decimal places, no rounding leftovers
Textnames, codes such as ZIP codes, item numbersleading zeros are kept
Dateorder and delivery datesthe basis for time axes and the date table

The icon on the left of the column header shows the type: ABC for text, 123 for Whole Number, 1.2 for Decimal Number. Clicking it changes the type.

One more exercise: numbers from a CSV file

Task After importing the CSV file, Amount and Quantity are still text. Change the data type of Amount to Decimal Number and of Quantity to Whole Number.

ABC
1 OrderID Amount Quantity
2 1 1798.00 2
3 2 59.70 3
4 3 596.00 4
5 4 39.80 2
6 5 1145.00 5

This exercise is part of Premium.

Premium unlocks every exercise in every lesson, unlimited practice with fresh tasks and the final test with certificate.

See Premium Already Premium? Log in

The first exercise in this lesson is free.

In real Power BI

  1. Split a column: select it, Home, Split Column, By Delimiter. Pick the delimiter and, if needed, "Each occurrence of the delimiter".
  2. Data type: click the icon in the column header or Transform, Data Type.
  3. Locale: if a CSV file uses a different decimal separator, right-click the header, Change Type, Using Locale, then pick the data type and locale.

Common mistakes

ZIP code as a number

As a Whole Number, 02108 becomes 2108, and a relationship to the territory table no longer finds the code. Codes nobody calculates with stay text.

Whole Number for amounts

59.70 would become 60. Over many orders this adds up to a visible gap against the sales in the accounts.

Automatically detected types

When loading a CSV file, Power Query often adds a Changed Type step of its own. It is based on the first rows and can be wrong. Always check it.

Frequently asked questions

Where do I change data types: Power Query or the model?

In Power Query. There the value is converted as it loads. You can change the type in table view too, but errors in the values only show in the editor.

What does Error in a cell mean?

The value did not fit the data type, for example a word in a number column. Remove Rows, Remove Errors deletes these rows; finding the cause is better.

Learn this next: merge queries

Fetch columns from a second table, like VLOOKUP in Excel.

Merge queries

Write to us

Choose language

Select your preferred language