Forum Discussion

ansa_naz's avatar
ansa_naz
Continued Contributor
6 years ago
Solved

Why does my DAX Datetable not include dates for 2020?

My DAX datetable is:

 

Date = 
VAR MinYear = 2018
VAR MaxYear = 2020
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] ),
    "Month End", EOMONTH([Date],0)
)

 

Why are there no dates for 2020 in this calendar table, only 2018 and 2019?

2 Replies

  • az38's avatar
    az38
    Community Champion

    Hi ansa_naz 

    check if in your data exists data from 2020 because in CALENDARAUTO() function range of dates is calculated automatically based on data in the model.

    You can also use CALENDAR() function instead https://docs.microsoft.com/en-us/dax/calendar-function-dax

     

    do not hesitate to give a kudo to useful posts and mark solutions as solution

    • ansa_naz's avatar
      ansa_naz
      Continued Contributor

      Thanks for that, didnt realise the CALENDARAUTO function uses dates in the data model. Used CALENDAR and it works perfectly, cheers