Forum Discussion
DAX Error: Creating new Date Table
- Anonymous5 years ago
Hi A-IT
Your dax may have someting wrong in the format of Addcolumn function.
It should be like addcolumns(table,"Name1","Expression1","Name2","Expression2"...)
For more info to Addcolumn function: Addcolumn
I update your dax and build a calculated table as below.
Date = ADDCOLUMNS ( CALENDAR ( DATE ( 2018, 1, 1 ), DATE ( 2024, 12, 31 ) ), "DateAsInteger", FORMAT ( [Date], "YYYYMMDD" ), "Year", YEAR ( [Date] ), "Month Number", FORMAT ( [Date], "MM" ), "Year/Month Number", FORMAT ( [Date], "YYYY/MM" ), "Year/Month Short", FORMAT ( [Date], "YYYY,mmm" ), "Month Short", FORMAT ( [Date], "mmm" ), "Month Long", FORMAT ( [Date], "mmmm" ), "Day #", WEEKDAY ( [Date] ), "Day of Week", FORMAT ( [Date], "dddd" ), "Quarter", "Q" & FORMAT ( [Date], "Q" ), "Year Quarter", FORMAT ( [Date], "YYYY" ) & "/Q" & FORMAT ( [Date], "Q" ), "Week of Year", WEEKNUM ( [Date] ) )Result:
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi A-IT
Your dax may have someting wrong in the format of Addcolumn function.
It should be like addcolumns(table,"Name1","Expression1","Name2","Expression2"...)
For more info to Addcolumn function: Addcolumn
I update your dax and build a calculated table as below.
Date =
ADDCOLUMNS (
CALENDAR ( DATE ( 2018, 1, 1 ), DATE ( 2024, 12, 31 ) ),
"DateAsInteger", FORMAT ( [Date], "YYYYMMDD" ),
"Year", YEAR ( [Date] ),
"Month Number", FORMAT ( [Date], "MM" ),
"Year/Month Number", FORMAT ( [Date], "YYYY/MM" ),
"Year/Month Short", FORMAT ( [Date], "YYYY,mmm" ),
"Month Short", FORMAT ( [Date], "mmm" ),
"Month Long", FORMAT ( [Date], "mmmm" ),
"Day #", WEEKDAY ( [Date] ),
"Day of Week", FORMAT ( [Date], "dddd" ),
"Quarter", "Q" & FORMAT ( [Date], "Q" ),
"Year Quarter",
FORMAT ( [Date], "YYYY" ) & "/Q"
& FORMAT ( [Date], "Q" ),
"Week of Year", WEEKNUM ( [Date] )
)
Result:
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you! This worked great. I need to go look at the two side by side and determine where I made the error. It's awesome that I can create the date table from scratch in seconds now!
- A-IT5 years agoNew Member
I found the error when looking at them side by side. I wrote the DAX as:
'Month Number' = FORMAT( [Date], "MM"). It should not use "=" in the syntax. It should be:
"Month Number", FORMAT ( [Date], "MM" ),
I'm learning, thank you!