Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
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?
Solved! Go to Solution.
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)
)
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)
)
| User | Count |
|---|---|
| 6 | |
| 6 | |
| 4 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 24 | |
| 17 | |
| 10 | |
| 7 | |
| 6 |