top of page

Power Query: Normalizing denormalized table

  • Marek Vavrovic
  • May 3, 2022
  • 2 min read

Sample data:

I have this Denormalized table, and I want to put the table into 3rd normal form.

ree
  1. Load table into Power Query


ree

2. Duplicate the original table 3 times


ree

3. Now we have the original table and 3 copy of it.

ree

4.

The original table has LastName column and 3 sets of FirstName and Age.


Copy1 table

Create a first Table that will contain LastName, FirstName, Age columns, and remove the other columns.

ree

Copy2 table

Highlight LastName, FirstName, Age, and remove other columns.

ree

Copy3 table

Highlight LastName, FirstName, Age, and remove other columns.

ree

Appending tables


Now each of these copy tables contains LastName, FirstName and Age and we can Append them as New.


ree

Choose Copy1 ,2 and 3 for Append.

ree

The result is a table with 1 LastName column and we also have 3 columns for Age and FirstName with NULL values.


ree

Next step is to highlight all 3 Age columns and apply Merge Columns transformation. That will help us to get rid of the null values.


ree

Separator None, choose a column name for the merged column.


ree

You can see the merged column Age.1 on the right side. Now apply the same transformation for all 3 FirstName columns. Highlight them > Merge Columns.


ree

At this stage we manage to remove the nulls.


ree

We can remove empty now.


ree

This is done. Do not load into Excel yet, just create the connections.


ree

In Excel, click on the connection from the Appended file. Choose Load To...


ree

Specify where you want to load that table.


ree

We have loaded just the normalized table, the rest of them are connections and won't be loaded into excel.


ree


Another way how to do it without duplicating the original table



Unpivot only selected columns.

ree

Add a Custom column



ree

Add a Custom Column for FirstName


ree

Add a Custom Column for Age


ree

Fill Down for FirstName column, Fill Up for Age Column


ree

Group by LastName, FirstName, Age

Operation: All Rows

ree

Remove the last column: Count


ree

Result



ree

Subscribe Form

©2020 by MaVa Analytics. Proudly created with Wix.com

bottom of page