Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Query regarding Date

Hello All, Can anyone pls tell me whats the difference between using date (year and month only) as hierarchy vs year and month as calculated column from calendar table. Left image has date hie...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi,Anonymous 

    In Power BI, the difference between using dates as hierarchies and using years and months as calculated columns in a calendar table is the way the data is organized and displayed.

    1.Firstly you can only use dates as hierarchies if your data column type is Date, Date/Time, etc. Secondly, after you use it, Power BI automatically creates the year, quarter, month, and day hierarchies for you. This is useful for you to work with more complete date data, but it may also show all possible time periods, including those that don't exist in the dataset. As you can see in the following figure, this is true not only in the matrix view, but also in, for example, the slicer view.


    You can also turn off the hierarchy here:

    2.Please note:

    Make sure you have the option to turn on the date hierarchy in your Settings:

    Here are the links to the relevant documents:

    Auto date/time in Power BI Desktop - Power BI | Microsoft Learn

    If the date columns of your two tables have a relationship, the date columns of only one table have a hierarchy:


    2.On the other hand, when using year and month as calculated columns, you have more control over what is displayed because you are defining the columns yourself. This means that only the months in the dataset will be displayed in the visualization, as shown in the right image you mentioned, and it is also possible that powerbi recognizes the output of your calculated columns as a text type. If you only need to report on a specific period and don't need the full hierarchy that Power BI provides by default, then this approach will make your visualization more concise and efficient.

    3.Here is a link to the relevant documentation which I hope you find helpful:

    Auto date/time guidance in Power BI Desktop - Power BI | Microsoft Learn

    Create date tables in Power BI Desktop - Power BI | Microsoft Learn

    Set and use date tables in Power BI Desktop - Power BI | Microsoft Learn

    Best Regards,

    Leroy Lu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.