Forum Discussion
Date Hierarchy does not get generated
my Date field named created_at is a Date/Time in Power Query when I load the data but not in the model (Data view). Why? How do I make the date hierarchy to get generated automatically?
martinmark You will have to first create the columns in the table which are required for creating the Date Hierarchy - possible in Direct Query Mode by using DAX. Then, you can use those columns to create a hierarchy as required.
Note - Use MonthNum column to sort MonthName and if you want full Month name you can modify the DAX calculation as required.
Create below DAX Calculated columns in the table in which you have created_at column -
Year = YEAR('Table'[created_at]) Quarter = "Q" & QUARTER('Table'[created_at]) MonthNum = MONTH('Table'[created_at]) MonthName = SWITCH( MONTH('Table'[created_at]), 1, "Jan", 2, "Feb", 3, "Mar", 4, "Apr", 5, "May", 6, "Jun", 7, "Jul", 8, "Aug", 9, "Sep", 10, "Oct", 11, "Nov", 12, "Dec" )π‘ Helpful? Give a Kudos π β keep the community growing
β Solved your issue? Mark as Solution βοΈ β help others find it faster
Best regards,
Rupasree Achari | BI & Fabric Analytics Engineer
11 Replies
- divyedSuper User
Hello martinmark ,
Sometimes you may see the difference ( when auto detect is off) , try below steps to force the model to recognize it as a Date/Time :
-
In Power BI Desktop, go to the Data View
-
Click on your created_at column.
-
Look at the top ribbon under column tools.
-
Change Data Type to Date/Time (or Date if you don't need the timestamp).
-
Change Format to your preferred date format
I hope this helps,
Did I answer your query ? Mark this as solution if this helps, Kudos are appreciated.
Cheers,
-
- Rupa01Solution Sage
Hi martinmark.,
Date Hierarchy is automatically created in Power BI when Time Intelligence option is enabled in your current PBI Desktop File - File > Options & Settings > Options > Current File > Data Load > Time Intelligence (enable)
Note that this will only work when the table storage mode is 'Import', column data type is Data or DateTime and the column is not in the many side of the relationship.
Microsoft Reference - Auto date/time in Power BI Desktop - Power BI | Microsoft Learn
π‘ Helpful? Give a Kudos π β keep the community growing
β Solved your issue? Mark as Solution βοΈ β help others find it faster
Best regards,
Rupasree Achari | BI & Fabric Analytics Engineer - martinmarkNew Member
- Rupa01Solution Sage
martinmark, Since the table is in Direct Query Mode, time intelligence option will not provide you automati Date Hierarchy creation - its a condition stated in the Microsoft Reference - Auto date/time in Power BI Desktop - Power BI | Microsoft Learn
If you need Date hierarchy, you will have to manually create date hierarchy, Reference - How to Create Date Hierarchy in Power BI? [With Examples]
π‘ Helpful? Give a Kudos π β keep the community growing
β Solved your issue? Mark as Solution βοΈ β help others find it faster
Best regards,
Rupasree Achari | BI & Fabric Analytics Engineer- martinmarkNew Member
Hi Rupa01 , thanks for your further answer!
The problem is that none of the methods shown in the article apply to my case.- Power BI auto create date hierarchy: as we said, this does not work because it is a DirectQuery connection
- Add date hierarchy Power BI: the "Select the Year column -> click..." method doesn't work because I do not have a Year column. My date column is a single column of timestamps as shown in the my question
- the SharePoint List method is basically the same as the first and Date Hierarchy does not get generated automatically in my case.
- Power BI Add Week to Date Hierarchy: This does not work because I am in DirectQuery mode
How come is this such of a challenge?Thanks
- Prince0011Solution Sage
The reason your Date Hierarchy is not being generated automatically is usually because Power BI is no longer recognizing created_at as a true Date/Time column in the semantic model, even though it was a Date/Time type in Power Query.
Power BI only creates the automatic hierarchy when:
The column data type in the Model view/Data view is Date or Date/Time.
The Auto date/time feature is enabled.
The column is not being treated as Text or another data type after loading.
You can check the following:
1. Verify the data type in the model
Go to:
Data view β Select created_at column β Column tools
Check:
Data type = Date/Time
Format = your preferred date format
If it shows Text, change it to Date/Time.
2. Check Auto Date/Time setting
Go to:
File β Options and settings β Options β Current File β Data Load
Enable:
β Auto date/time
Then refresh the model.
Note: This setting must be enabled before Power BI creates the hidden date tables.
3. Check if you are using a DirectQuery or composite model
Automatic date hierarchies are not always available depending on the storage mode and model design.
For enterprise models, the recommended approach is usually not to rely on Auto Date/Time.
4. Recommended approach: Create a Calendar table
For production reports, create a proper Date table:
Calendar = CALENDAR( MIN('Table'[created_at]), MAX('Table'[created_at]) )Add columns:
Year = YEAR('Calendar'[Date]) Month = FORMAT('Calendar'[Date], "MMM") Month Number = MONTH('Calendar'[Date]) Day = DAY('Calendar'[Date])Then:
Mark it as Date table
Create a relationship:
Calendar[Date] β Table[created_at]
Use the Calendar fields in visuals.
This gives better control for:
Time intelligence
Fiscal calendars
Sorting months correctly
Year-over-year analysis
So, if this is a small report, enabling Auto Date/Time may solve it. For a production Power BI model, a dedicated Calendar table is the recommended solution.
For more information:
Auto date/time in Power BI: https://learn.microsoft.com/power-bi/transform-model/desktop-auto-date-time
Create and use date tables in Power BI: https://learn.microsoft.com/power-bi/transform-model/desktop-date-tables
π‘ Helpful? Give a Kudos π β keep the community growing.
β Solved your issue? Mark this as the Accepted Solution βοΈ
Best regards, Prince Singh | Data Science & Microsoft Fabric Enthusiast
- ryan_mayuSuper User
you can create a new column
date2 = DATEVALUE('Table'[date])then you can see the hierachy for the new columnpls see the attachment below- martinmarkNew Member
hi ryan_mayu. unfortunately this does not work as the column used is not recognised as date in the first place