in this Power BI Tutorial, we will learn about Power BI Date Hierarchy. Also, we will discuss:
- What is Hierarchy?
- Introduction to Power BI Date hierarchy.
- Date hierarchy benifits and examles.
- Power BI auto create date hierarchy
- Power BI create date hierarchy from date
- Power BI create custom date hierarchy
- Power BI create date hierarchy with week
What is hierarchy?
A hierarchy is a pyramid-like structure that organizes and ranked our data according to the power of importance.
In a hierarchy, every level has one higher and one lower neighbor.
Introducing to Power BI Date hierarchy
Microsoft provides a built-in function in Power BI known as Date hierarchy.
By default, Power BI detects and organizes the date data in the hierarchy automatically. It helps to display the hierarchy of year, quarter, month, and day.
The data hierarchy is a way of structuring our data table for comforting drilling down and up the data based on different grouped time slices.
A Power BI Date hierarchy looks like this:
Date hierarchy benifits and examples
The data hierarchy features make the data displaying more convenient and intuitive. It is an effective approach to speed up the report data access and restrict users from overstretching reports straight away.
Examples of date hierarchy are:
- Year-month hierarchy
- Year-month-quarter hierarchy
- Year-month-week hierarchy
Power BI auto create date hierarchy
Power BI can create a date hierarchy automatically, by configuring auto date/time globally or for the current file.
The global option applies to the new Power BI Desktop file, and it can be turned on/off at any time. Similarly, the current file option can also be turned on/off at any time.
To configure these option on Power BI go to file > options and setting > options > data load(global/current file) > Time intelligence.
This is how we can configure the auto date/time to create a built-in hierarchy in Power BI. By checking this option, a date hierarchy will create automatically on the Power BI data model.
Power BI Create date hierarchy from date
Now we will see how to create a date hierarchy from date in Power BI with a step-by-step guide.
For example, here we have sample data of a product’s financial report which we have loaded in Power BI Desktop.
On Power BI Desktop, go to model > date(right-click) > create hierarchy.
Then it will create a new date hierarchy on the data model. we can customize its name and other few options on the Properties field.
Now we will create a table visually using this date hierarchy on the report page. It will look like this:
For a better understanding, here we are using another column(i.e. segment). This is how to Create a date hierarchy from the date on Power BI.
Power BI create custom date hierarchy
We create different types of custom date hierarchies, such as:
- Year-Month hierarchy
- Year-Quarter-Month hierarchy
- Year-Month-Week hierarchy
Example-1: create Year-Month hierarchy
On Power BI Desktop, go to model > date(right-click) > create hierarchy. It will create a new data hierarchy.
On the properties pane, rename the Hierarchy name to Year-Month Hierarchy. On the hierarchy field, select the year and month column to customize the Hierarchy like this:
We can see a Year-Month hierarchy is created on the data model. To visualize this data hierarchy, here we use a table chart:
Like, Year-Month hierarchy we can create a Year-month-quarter hierarchy and Year-month-week hierarchy in the same process.
Read Power bi date filter
Power BI create date hierarchy with week
To create a date hierarchy with a week we have to follow these below steps.
Here we create a table by applying this code. It will create a table as Date having some column, such as year, month, a particular days (i.e. starting date to ending date), week, quarter, etc.
Date = ADDCOLUMNS ( CALENDAR (DATE(2017,1,1), DATE(2017,12,31)), "DateAsInteger", FORMAT ( [Date], "YYYYMMDD" ), "Year", YEAR ( [Date] ), "Monthnumber", FORMAT ( [Date], "MM" ), "YearMonthnumber", FORMAT ( [Date], "YYYY/MM" ), "YearMonthShort", FORMAT ( [Date], "YYYY/mmm" ), "MonthNameShort", FORMAT ( [Date], "mmm" ), "MonthNameLong", FORMAT ( [Date], "mmmm" ), "DayOfWeekNumber", WEEKDAY ( [Date] ), "DayOfWeek", FORMAT ( [Date], "dddd" ), "DayOfWeekShort", FORMAT ( [Date], "ddd" ), "Quarter", "Q" & FORMAT ( [Date], "Q" ), "YearQuarter", FORMAT ( [Date], "YYYY" ) & "/Q" & FORMAT ( [Date], "Q" ) )
Now click on DayOfWeek > Create hierarchy. It will create a week hierarchy on the table.
Now, will add Date to this hierarchy to create a date hierarchy with week. For this click on the Date > Add to hierarchy > DayOfWeek Hierarchy.
We can see the date will add to the hierarchy.
Let’s use this hierarchy on the Power BI report. It will come like this:
You may like the following Power BI tutorials:
- Power BI Slicer between two dates
- Microsoft Power BI KPI Visual
- Power bi slicer multiple columns with examples
- Power bi slicer checkbox
- Microsoft Power BI Card
- Power BI Measure IF with Examples
- Power Bi Time Intelligence Function
From this Power BI Tutorial, we learned all about the Power BI Date hierarchy. Also, we discussed:
- What is Hierarchy?
- What is Power BI Date hierarchy?
- What are the benifits and examles of Power BI Date hierarchy?
- How to create date hierarchy automatically on Power BI?
- How to create date hierarchy from date on Power BI?
- How to create custom date hierarchy?
- How to create date hierarchy with week on Power BI?
After working for more than 15 years in Microsoft technologies like SharePoint, Office 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Out audiences are from the United States, Canada, United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a SharePoint MVP(8 times), check out My MVP Profile. I have also worked in companies like HP, TCS, KPIT, etc.