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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
A-IT
New Member

DAX Error: Creating new Date Table

I'm attempting to write a DAX that will create a new Date Table. I tried to use the following:

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 Table'[Date] )

The DAX works when I put them into the individual columns. The issue is when I try to create the table in one function.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

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:

1.png

 

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. 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

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:

1.png

 

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!

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!
Anonymous
Not applicable

Hi @A-IT 

Addcolumn functions works on calculate column ....If you want a table the use the below function

//

Date =

VAR MinYear = YEAR ( MIN ( Sales[Order Date] ) )

VAR MaxYear = YEAR ( MAX ( Sales[Order Date] ) )

RETURN

ADDCOLUMNS (

    FILTER (

        CALENDARAUTO( ),

        AND ( YEAR ( [Date] ) >= MinYear, YEAR ( [Date] ) <= MaxYear )

    ),

    "Calendar Year", "CY " & YEAR ( [Date] ),

    "Month Name", FORMAT ( [Date], "mmmm" ),

    "Month Number", MONTH ( [Date] )

)
Note:Sales[Order Date]--> change this based on your table which has date column

 

Hope it resolves your issue? Please consider accepting it as the solution to help the other members find it more quickly.


Appreciate your Kudos, Press the thumbs up button!!👍




Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.