Power BI: Data Analysis for Business Intelligence

The Flat File

We will prepare a Flat-File which is much smaller than the original database to use in Excel for reporting.

We will use Power Query, prepare a new table from existing tables and then copy this table to Excel.

Open Power Query from PBI home menu transform data button.

Power Query is the tool for transforming the data

Here we will create a new table by merging columns from existing tables. We can merge 2 tables in one shot so we will have to do the merge process 4 times, to get all the necessary columns.

On the Home menu in PQ click Combine > Merge Queries > Merge Queries as New

A new query is practically a new table

In the Merge dialogue Select Orders Table and Products Table, select Product ID columns for the link between these 2 tables and press OK.

The relation keys for Orders and Products tables are Product ID columns

Now we have a new table named Merge1, rename under Query Settings Properties as Flat File.

The new Flat-File table

We will again merge, but this time not as a new query

Combine > Merge Queries > Merge Queries

We now want to adjust the current (Flat-File) query we created

This time merge the new table Flat File with Customer table taking all columns except customer ID (this already exists in Flat File.

Do the merge for the Country and the Employee tables. You have to show connections each time and exclude already existing columns.

We have to delete the Order ID column and change the date to month.

Right-click on the Order ID column and select Remove from the drop-down list.

Then under the Transform menu select Date > Month > Month.

The date column will show the month number

Rename the column as Month.

We have one more step; we must group the table.

Under the transform menu, press the Group By button.

Click Advanced, add all columns for grouping except Units Sold, Price and Cost columns. We will aggregate the Units Sold column and add calculated columns for revenue and cost.

Add Units Sold as a new aggregation column, select Sum operation. Press OK.

The Flat-Table has 2 million rows, which some of which are the same as there is no day breakdown in the Table.
We will group the recurring rows of the table and take sum of the column with numeric values (Units Sold).

Press the Close & Apply button under the Home menu, we land in the PBI window. We have a flat-file of 229.560 rows and one header row.

We will now add the Revenue and Total Cost columns.

First, we will delete the Price and Cost columns; on the fields pane click on the three dots, select Delete on the drop-down list. Do this for both columns.

Under the Table Tools menu select New Column, at the formula bar write below formula:

RevenueF = 'Flat File'[Units Sold] * RELATED(ProductsTable[Price])

Add another column for cost:

CostF = 'Flat File'[Units Sold] * RELATED(ProductsTable[Cost (£)])

Right-click on the month column and select the Copy table.

Copy the table and paste it into a blank Excel workbook

Paste the table to an empty Excel workbook to go on with the Analysis, Reporting, Visualisation with EXCEL.

Next, we will explore the Power BI service, distribute our reports online over the internet and mobile devices, have a look at the AI and connection to systems for automation.