PowerPivot | Transforming data (Power Query) exercise | Change data types of columns in world population table

This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.

Software ==> PowerPivot  (75 exercises)
Version ==> Excel 2013 and later
Topic ==> Transforming data (Power Query)  (7 exercises)
Level ==> Relatively easy
Subject ==> Power BI training
Before you can do this exercise, you'll need to download and unzip this file (if you have any problems doing this, click here for help).

You need a minimum screen resolution of about 700 pixels width to see our exercises. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

Open up the workbook called Tables in the above folder, and have a look at the Populations worksheet:

Table of country populations

We'll import this data into an Excel worksheet, tweaking it along the way.

Now close this workbook down, and create a new workbook. 

You could use try loading the source data from the original Wikipedia page at http://bit.ly/14wM1IU if you have an Internet connection, although this may not be in the same format by the time you do the exercise.

In Power Query, choose to create a query based on this workbook:

Power Query from Excel

The option you'll need to choose.  Make sure you choose the table called Populations, not the one with the much longer name.


Do the following things to make this table easier to read:

  1. Tell Power Query to use the first row as column headings.
  2. Delete the Source column (we don't need it).
  3. Change the data type of the Date column to Date.
  4. Change the data type of the Population column to Whole Number.
  5. Shorten the name of the Country column.

You should now have something like this:

Cleaner table

It's looking a bit more manageable!

To use this data in Excel, you'll have to turn the percentage columns into numbers.  Try doing this, and you'll see this doesn't work:

Percentages giving errors

The % sign is messing things up!


Undo this (except it's not undoing, it's deleting the last step of the query), and replace values in the % of world population column to replace all % symbols with spaces.  You should now be able to change the data type to Decimal Number.

Load this data into your (presumably empty) PowerPivot data model:

PowerPivot table

We've changed the format of the date to make it look tidier.  It's a shame we didn't make the Rank column a number too!

Change the data type of the Rank column in PowerPivot, then save your workbook as Populations and close it down.

You can unzip this file to see the answers to this exercise, although please remember this is for your personal use only.
This page has 0 threads Add post