Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

Setting Date Hierarchy - Extract month from the date

Hi All,

 

Every time I load a new set of data into Power Bi, I have to set the Date Hierarchy for the graph:

 

Graph 1: Initial status

 

Cityisremy_0-1648090177976.png

 

I have to set the Date Hierarchy manually to "month" only so that the graph becomes the shape I need. 

 

Graph 2: Finished

Cityisremy_1-1648090401768.png

 

Is there a way that I can automate this process? Like setting a variable for the month?

 

Thanks for your ideas.

 

Regards,

Remy

1 ACCEPTED SOLUTION

@Anonymous , Create a date table and join with date of your table

 

Addcolumns(calendar(date(2020,01,01), date(2021,12,31) ), "Month" , month([date])
, "Year", year([date])
, "Month Year", format([date],"mmm-yyyy")
, "Month year sort", year([date])*100 + month([date])
, "Month",FORMAT([Date],"mmmm")
, "Month sort", month([DAte])

)

 

Mark month sort as sort column of the month and use month from this table

 


To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.  

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@Anonymous , The better way is to use a date table and have column month there and use that

 

Month Year = FORMAT([Date],"mmmm")
Month Year sort = month([DAte])

Anonymous
Not applicable

Hi Amitchandak,

 

Thank you for answering my question. 

 

Can you elaborate a bit more on the answer? It looks great but I cannot fully understand it.

 

Remy

@Anonymous , Create a date table and join with date of your table

 

Addcolumns(calendar(date(2020,01,01), date(2021,12,31) ), "Month" , month([date])
, "Year", year([date])
, "Month Year", format([date],"mmm-yyyy")
, "Month year sort", year([date])*100 + month([date])
, "Month",FORMAT([Date],"mmmm")
, "Month sort", month([DAte])

)

 

Mark month sort as sort column of the month and use month from this table

 


To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.  

Anonymous
Not applicable

Thanks, AmitChandak,

 

Very Helpful!

 

Remy

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.