DEV Community

Odhiambo
Odhiambo

Posted on

A Comprehensive Guide to Publishing Power Bi Reports

Once you have selected your data source in a new session on Power Bi desktop application, load data into power query to transform it.

Getting data

In case of a mutli-sheet workbook in Excel, select sheet(s) you intend to work with. They will eventually be made into tables in Power Bi. Then click on transform data.

Transformdata

Ensure to check for inconsistent data from column filters. Standardize any inconsistent data as well as blanks and pseudo-blanks. Using the column filter we are able to see categories for each column at a glance. This would help identify blanks, inconsistencies and missing values.

Column filter

Click close and apply to load data into Power Bi.

Loading to Power Bi

Select the sheet from data pane and right click to rename it into something meaningful. Remember to save progress in location of our choice to avoid data loss.

Rename sheet

1. Total sales from all products.

Since we already have sales for each individual product, we simply use SUM function to get the total for the SalesAmount column. Click on New Measure, give it a descriptive name and enter the function:

Total sales

2. Profit Margin

Profit margin is calculated by profit/SalesAmount * 100. Since we already have the total value for sales amount calculated above, we will use SUMX to calculate the profit. Our new expression will be as shown:

SumX

The SUMX above encloses the profit for each row. It calculates profit for each row and also a sum at the end. For each row, this value is used to calculate the profit margin.

This will allow us to filter by country, product in the report view.

Filter

3. Change currency to USD

Currency is changed to USD from CAD for all columns that have currency using the formula below.

Shipping cost to USD

Shipping

Sales Amount to USD

Sales

Profit to USD

Profit

4. Missing or incorrect values

Missing data values can be standardized as pseudo blanks for text columns or to be null for numbers.

In addressing missing numeric values, median is the best option as it accounts for skewed data. Mode is recommended for text, categorical or nominal categorical data. Mean is advised for data with normal distributed data.

5. Model data

Modelling our data involves creating dimensions tables and a fact table. Click on Transform data in Power Bi to open Power Query. Duplicate the existing table to the number of total tables (dimension tables and fact tables) needed.

Except for the fact table, columns not needed in each dimension table are deleted. Columns in the fact table are kept as is to use in the subsequent steps of creating unique identifiers for all dimension tables.

Click on Close & Apply to effect the changes and return to Power Bi.

Tip: Always keep a copy of the original table/data.

Date Table

To create a date table, click on the New Table command in Power Bi.

Date

Enter the formula below to create the table:

Creating date table

CALENDARAUTO() generate a new date column based on all the dates in our data. To limit the use of possible unnecessary date columns that might exist in our data, eg. Date of Birth, we create new variables and determine the range our date should fall in. In this example, the MinDate looks for the earliest date an order was placed and the MaxDate returns the most recent date for delivery.

The filter is then used to give CALENDARAUTO() the date range to filter from based on these two values.

The other Date-related columns are derived from the date column returned by CALENDARAUTO() function.

Here is a view of our tables after the steps.

Tables

Creating unique identifiers

All our dimension tables will need unique identifiers to be linked to the fact table.

1. Create Unique ID in the dimension table

Click CustomerEmail from the customers table and select Remove Duplicates from the drop down.

Remove duplicates

Unique email identifiers remain.

From the Add Column tab, click on Index Column and the initiator of choice, in this case, Custom.

Custom

Define the desired index format and increment and click OK.

Index

I rename the column to CustomerID, this is what we will use to join it in the fact table. I also change the type to text. This just as a personal preference for columns that eventually may include a lot of records.

New column

NOTE: REPEAT THIS PROCESS FOR THE OTHER DIMENSION TABLES

2. Merge the Fields from the tables

Still in the Power Query editor, click on the fact table and select Merge Queries from the ribbon.

Select Left Outer Join with the fact table as the first table. You see from the image below we get all records matching. Click ok.

Merge queries

Click on the expand tables icon.

Expand table

Deselect all column names except the CustomerID. Our new fact table will have this column included.

New id column

Our CustomerID is now included in the fact table.

New table

Repeat for the other dimension tables.

The Relationship and view should be as shown

Relationship

6. Report and Dashboard

Go to the report view and select visualization build from the side panel as needed. Add your key overview metrics from the different values. This will from the dashboard as shown.

Report

Save your work and click on publish. Log in to a Power Bi account from the Power Bi Service online and select the option to create a workspace.

Workspace

Give the workspace a name. Log in to the Power Bi account from your desktop application and click on publish. Choose the same workspace created earlier to publish the report to. You have now published your report.

Create a new page on the Power Bi desktop application and give it a relevant name for specific metrics to be shown.

Report app

This will form the individual reports of your work.

Naming reports

The published work should reflect on the online Power Bi service.

Work online

Embedding

To embed the report in another online document such as a webpage, click on File then select the Embed report then Website or portal.

Embed

Copy the resulting iFrame for embedding inside a html document.

Iframe

Embed iframe

Your Power Bi Report page will appear on the html document.

Live document

Top comments (0)