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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
admin_xlsior
Post Prodigy
Post Prodigy

Can we make single column Date to have Auto date ?

Hi guys,

 

If I turn off the time intelligence - Auto date/time in Options, and then I created a Calendar table by using CALENDARAUTO(), can me me that 1 field Date only to have a date hierarchy automatic ? 

 

The reason I turn it off is because I have many tables with dates in it so I do not want it all to have hierarchy, but for that specific Calendar Dimension (table), obviously I want.

 

Thanks

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@admin_xlsior 

If you turn off the Auto Date Time then you need to add a Dates Table with the required hierarchy
You can use the following code to create a dates table. Order Date can be replaced with your fact table date column

 

Dates = 
VAR StartYear = YEAR( MIN(Orders[Order Date]) )
VAR EndYear = YEAR( MAX(Orders[Order Date]) )
VAR DatesColumn = 
    CALENDAR( 
        DATE(StartYear , 1 , 1),
        DATE(EndYear, 12 , 31)
    )
RETURN
ADDCOLUMNS(
    DatesColumn,
    "Month No" , MONTH([Date]),
    "Month Name" , FORMAT( [Date] , "Mmmm" ),
    "Year" , YEAR([Date]),
    "Month Year No" , (YEAR([Date]) * 100) + MONTH([Date]),
    "Month Year" , FORMAT( [Date] , "Mmm yyyy"),
    "Quarter" , QUARTER([Date]),
    "Qtr Name" , FORMAT( [Date] , "\QQ"),
    "Week Day" , WEEKDAY([Date],2),
    "Week" , FORMAT( [Date] , "Dddd" )  
)



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

2 REPLIES 2
Fowmy
Super User
Super User

@admin_xlsior 

If you turn off the Auto Date Time then you need to add a Dates Table with the required hierarchy
You can use the following code to create a dates table. Order Date can be replaced with your fact table date column

 

Dates = 
VAR StartYear = YEAR( MIN(Orders[Order Date]) )
VAR EndYear = YEAR( MAX(Orders[Order Date]) )
VAR DatesColumn = 
    CALENDAR( 
        DATE(StartYear , 1 , 1),
        DATE(EndYear, 12 , 31)
    )
RETURN
ADDCOLUMNS(
    DatesColumn,
    "Month No" , MONTH([Date]),
    "Month Name" , FORMAT( [Date] , "Mmmm" ),
    "Year" , YEAR([Date]),
    "Month Year No" , (YEAR([Date]) * 100) + MONTH([Date]),
    "Month Year" , FORMAT( [Date] , "Mmm yyyy"),
    "Quarter" , QUARTER([Date]),
    "Qtr Name" , FORMAT( [Date] , "\QQ"),
    "Week Day" , WEEKDAY([Date],2),
    "Week" , FORMAT( [Date] , "Dddd" )  
)



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Hi,

 

Yes, I actually did the same, but by adding it with DAX in front. But Thanks though, I know I just being lazy 😂

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.