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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
rliebau
Frequent Visitor

Creating Calendar Table with Variables - Min Date Incorrect

I am creating a Calculated Date table using Min and Max dates as the date range. Frequently I do this using dates from an imported table, but this time I manually entered the MinDate I want. No matter what I do the actual date range does not go past 1/1/2019. 

Here's my code:

 

 
Date = 
var MinDate = DATE(2014,1,1)
var MaxDate = EOMONTH(TODAY(),-1)
RETURN
ADDCOLUMNS(
    FILTER(
        CALENDARAUTO(),
        [Date]>= MinDate &&
        [Date]<= MaxDate
    ),
    "Year", YEAR([Date]),
    "Quarter Number", INT(FORMAT([Date], "q")),
    "Quater", "Q" & INT(FORMAT([Date], "q")),
    "Quarter Year", INT(FORMAT([Date],"q")) & "Q" & RIGHT(YEAR([Date]),2),
    "Month End", EOMONTH([Date],0))
 

 

It's clear that I want the variable MinDate to be equal to 1/1/2014, and I use the DATE() function to recognize that value as date.

 

Here are a few visuals of the Date table:

 

PBIX_Dates_Ex.PNG

 

It only created a date table with 1/1/2019 as the earliest date. What am I missing?

1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

Hi @rliebau 

Use CALENDAR instead of CALENDARAUTO:

Date =
VAR MinDate = DATE ( 2014, 1, 1 )
VAR MaxDate = EOMONTH ( TODAY (), -1 )
RETURN
    ADDCOLUMNS (
        CALENDAR ( MinDate, MaxDate ),
        "Year", YEAR ( [Date] ),
        "Quarter Number", INT ( FORMAT ( [Date], "q" ) ),
        "Quater", "Q" & INT ( FORMAT ( [Date], "q" ) ),
        "Quarter Year", INT ( FORMAT ( [Date], "q" ) ) & "Q"
            & RIGHT ( YEAR ( [Date] ), 2 ),
        "Month End", EOMONTH ( [Date], 0 )
    )

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Cheers  Datanaut

View solution in original post

3 REPLIES 3
rliebau
Frequent Visitor

I fixed it. I forgot that CALENDARAUTO() relies on a base datetime column in an existing table. I had one table imported already that only had a date range in 2019.

 

Here's the corrected code for anyone interested:

Date = 
var MinDate = DATE(2014,1,1)
var MaxDate = EOMONTH(TODAY(),-1)
RETURN
ADDCOLUMNS(
    CALENDAR(MinDate, MaxDate),
    "Year", YEAR([Date]),
    "Quarter Number", INT(FORMAT([Date], "q")),
    "Quater", "Q" & INT(FORMAT([Date], "q")),
    "Quarter Year", INT(FORMAT([Date],"q")) & "Q" & RIGHT(YEAR([Date]),2),
    "Month End", EOMONTH([Date],0))
AlB
Community Champion
Community Champion

Hi @rliebau 

Use CALENDAR instead of CALENDARAUTO:

Date =
VAR MinDate = DATE ( 2014, 1, 1 )
VAR MaxDate = EOMONTH ( TODAY (), -1 )
RETURN
    ADDCOLUMNS (
        CALENDAR ( MinDate, MaxDate ),
        "Year", YEAR ( [Date] ),
        "Quarter Number", INT ( FORMAT ( [Date], "q" ) ),
        "Quater", "Q" & INT ( FORMAT ( [Date], "q" ) ),
        "Quarter Year", INT ( FORMAT ( [Date], "q" ) ) & "Q"
            & RIGHT ( YEAR ( [Date] ), 2 ),
        "Month End", EOMONTH ( [Date], 0 )
    )

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Cheers  Datanaut

rliebau
Frequent Visitor

@AlB Thanks. I figured it out but you just barely beat me to it!

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.