Power BI training sessions always uncover common issues. The aim of this blog series is to address the common issues occurring in our Power BI training in Sydney, Melbourne, Brisbane, Perth, Adelaide and Canberra.
In this blog post, a step-by-step guide on creating product hierarchy is presented but let’s summarize the concepts covered so far:
1. Importing Data
Importing data refers to procuring the data tables into Power BI desktop or service. This step involves creating a connection with the data base to access the data.
Data Preparation involves ensuring that the data is capable of delivering value. In this phase, the raw data is manipulated to extract useful information from it.
3. Creating Date Table
The date Table is important for temporal analysis. The date table is created using the CALENDER() function or the CALENDERAUTO() function. Both of these functions have different input parameters and produce different results.
The model design consists of creating relationship between the data tables procured for the task at hand. The tables are linked on the basis of primary and foreign keys. If these keys are absent then the table cannot be linked to another table.
Surrogate Key is the unique identifier in any table. It is important to create a relationship between the two tables. This key acts as a primary key in one table and foreign key in the other.
Flattening of the table refers to linking the tables attached to the ends of the schema. In data modeling terminology it means changing the snow flake to star schema because star schema is the most preferred data model by industry experts.
Flattening of Product table is important due to two reasons. Firstly, it helps to organizes the data model and secondly, hierarchy can be created in the same table of the data model.
Power BI allows you to create Product Hierarchy for columns present in the same table.
To create Product Hierarchy:
1. Click on Model Tab in the left Ribbon.
2. Right Click on Product.
3. Click on Create Hierarchy.
4. In the General Section, Type Product Hierarchy in the Name field.
5. In the Advanced Section, Click on Product Type in the Hierarchy drop-down menu.
6. In the Advanced Section, Click on Product Line in the Hierarchy drop-down menu.
7. Click on Apply Level Changes in the Advanced Section.
Notice that a Product Hierarchy is created in the Product Table with Product lowest level of granularity and the Product Line as the highest grain.
Conclusion:
A data model consists of the right tables linked to each other with the correct relationship between them. This may seem as simple as loading the data into Power BI and creating the relationship using drag and drop. But in reality, it is not. When the data model is created in the form of star schema, many problems start to emerge such as missing surrogate key and hanging dimensions. Another commonly used feature is the hierarchy. However, hierarchy cannot be created unless all the columns are present in the same table.