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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
DebbieE
Community Champion
Community Champion

Created Date table with DAX but Dates are from 1899

I have created a DAX table using CALENDARAUTO But I dont want a date table with dates previous to what is in my data. I dont need dates from 1899. Is there any way I can have a date table that starts at say the start of your data set and ends at the end of the year of your data set? 

 

Dim Date = VAR BaseCalendar = CALENDARAUTO(12)
RETURN GENERATE (
BaseCalendar,
VAR BaseDate = [DATE]
VAR YearDate = YEAR( BaseDate)
VAR MonthNumber = FORMAT(MONTH( BaseDate),"00")
VAR MonthName = FORMAT(DATE(1,MonthNumber,1),"MMMM")
VAR DayOfWeek = WEEKDAY(BaseDate)
VAR WeekDay = FORMAT(BaseDate,"DDDD")
VAR WeekNo = WEEKNUM(BaseDate)
VAR Quarter = ROUNDUP(Month(BaseDate)/3,0)
RETURN ROW (
"DateKey",YearDate&MonthNumber&FORMAT(DAY(BaseDate),"00"),
"Day", FORMAT(DAY(BaseDate),"00"),
"Year",YearDate,
"Quarter",Quarter,
"Month No", MonthNumber,
"Month",MonthName,
"Day of Week", DayOfWeek,
"Week Day",WeekDay,
"WeekNo", WeekNo
))
 
 
1 ACCEPTED SOLUTION
DebbieE
Community Champion
Community Champion

Yes, that is what I looked at and as I said, I still didnt understand how to apply that to what I already had set up.  Ive decided to not use a DAX Table for dates for the following reasons.

 

Every time I add a new fields into the Date table all my visuals reset from the date hierarchy to the date causing my visuals to error until I go through and change everything back to hierarchy, I dont want this to happen when I decide to add a new column.

 

Every time I decide to use the Date table the full DAX code appears in its window and I have to re hide it. This is really annoying when your trying to use fields from the date table

 

So for this Ive decided to create the date time dimension in my database as a table

View solution in original post

10 REPLIES 10

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.