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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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