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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
SLJN
Regular Visitor

how do I create a date table with the date format YYYY-MM-DD 00:00 real time data, and weeknr

Hi! 

 

Im trying to create a date table with timestamp and correct weeknumber (monday as first day). But I'm stuck. 

Date = 

 

VAR MinDate = DATE(YEAR(TODAY())-2,"-01-01", NOW)
VAR MAxDate = YEAR(TODAY(),NOW)


ADDCOLUMNS (
FILTER(
CALENDERAUTO(),
YEAR ([Date]) >= MinDate &&
YEAR ([Date]) <= MaxDate,

 "Year" ,YEAR ( [Date] ),

MONTH, FORMAT ([Date], "m" ),

"MonthNr", FORMAT ( [Date], "MM" ),

"Day", DAY ( [Date] ),

"WEEKDAY([Date],2)

)

 

I can't seem to get it right, how should I solve this? 

1 ACCEPTED SOLUTION
AUaero
Responsive Resident
Responsive Resident

The DAX you posted isn't valid - maybe a copy/paste error?

The code below should get you what you need.  As far as formatting the date field as yyyy-mm-dd hh:mm:ss, you can specify the format of the column after you create the table.

Date = 
VAR MinDate = DATE(YEAR(TODAY())-2, 1, 1)
VAR MaxDate = TODAY()

RETURN
ADDCOLUMNS (
    CALENDAR(MinDate, MaxDate),
    "Year", YEAR([Date]),
    "MonthNr", FORMAT([Date], "MM"),
    "Day", DAY ([Date]),
    "DOW", WEEKDAY([Date],2),
    "WeekNumber", WEEKNUM([Date], 1)
)

 

AUaero_0-1670964181779.png

 

View solution in original post

1 REPLY 1
AUaero
Responsive Resident
Responsive Resident

The DAX you posted isn't valid - maybe a copy/paste error?

The code below should get you what you need.  As far as formatting the date field as yyyy-mm-dd hh:mm:ss, you can specify the format of the column after you create the table.

Date = 
VAR MinDate = DATE(YEAR(TODAY())-2, 1, 1)
VAR MaxDate = TODAY()

RETURN
ADDCOLUMNS (
    CALENDAR(MinDate, MaxDate),
    "Year", YEAR([Date]),
    "MonthNr", FORMAT([Date], "MM"),
    "Day", DAY ([Date]),
    "DOW", WEEKDAY([Date],2),
    "WeekNumber", WEEKNUM([Date], 1)
)

 

AUaero_0-1670964181779.png

 

Helpful resources

Announcements
FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.