Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Problem in generate dCalendar

I try generate my dCalendar but when a using the function List.Dates a had this error.

I having usind brazilian format date. Can help me?

 

  • Anonymous's avatar
    Anonymous
    6 years ago

    It might be better to build your date table using DAX instead. There are several ways to do so and the code below should work for you. It dynamically builds a date table from dates in your fact table. 

     

    You can adjust the code to remove or add additonal columns as needed.

     

    Thanks 

     

    Date =
    VAR Dates =
    CALENDAR (
    DATE ( YEAR ( MIN ( 'Fact Table'[Date] ) ), 1, 1 ),
    DATE ( YEAR ( MAX ( 'Fact Table'[Date] ) ), 12, 31 )
    )
    RETURN
    ADDCOLUMNS (
    Dates,
    "Year", YEAR ( [Date] ),
    "Quarter", FORMAT ( [Date], "q" ),
    "Month", MONTH ( [Date] ),
    "Month_Name", FORMAT ( [Date], "mmmm" ),
    "Month_Short_Name", FORMAT ( [Date], "mmm" ),
    "Year_Quarter", YEAR ( [Date] ) & "-Q"
    & FORMAT ( [Date], "q" )
    )

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    It might be better to build your date table using DAX instead. There are several ways to do so and the code below should work for you. It dynamically builds a date table from dates in your fact table. 

     

    You can adjust the code to remove or add additonal columns as needed.

     

    Thanks 

     

    Date =
    VAR Dates =
    CALENDAR (
    DATE ( YEAR ( MIN ( 'Fact Table'[Date] ) ), 1, 1 ),
    DATE ( YEAR ( MAX ( 'Fact Table'[Date] ) ), 12, 31 )
    )
    RETURN
    ADDCOLUMNS (
    Dates,
    "Year", YEAR ( [Date] ),
    "Quarter", FORMAT ( [Date], "q" ),
    "Month", MONTH ( [Date] ),
    "Month_Name", FORMAT ( [Date], "mmmm" ),
    "Month_Short_Name", FORMAT ( [Date], "mmm" ),
    "Year_Quarter", YEAR ( [Date] ) & "-Q"
    & FORMAT ( [Date], "q" )
    )
  • v-easonf-msft's avatar
    v-easonf-msft
    Community Support

    Hi , Anonymous 

    If the imported date format does not meet your requirements, you can try the following operations to change type with locate:

    Right click the date column ->click "Change Type"->click"Using Locate"

     

    Best Regards,
    Community Support Team _ Eason
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • v-easonf-msft's avatar
    v-easonf-msft
    Community Support

    Hi, Anonymous Could you please tell me whether your problem has been solved?
    If it is,  please mark the helpful replies or add your reply as Answered to close this thread.

    Best Regards,
    Community Support Team _ Eason