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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Miguel_Rojo
Helper II
Helper II

Date Error: Cannot identify the table that contains [Date] column.

Hi community!

Power bi is having problems to create a "Calendar Table" using my code (which in my opinion is correct).

After I provided the code (please check below), I get the next error: "Cannot identify the table that contains [Date] column."

 

I need the table to create a relation between my other two tables (both tables have multiples records in their respective "Date" columns, and the data type of those columns is "Date".

 

Do you know what's wrong? As you can see, indeed the table and column to which I'm making reference exists and are correct (I provide an screen shot of my two single tables in the model).

 

 

CODE:

 
Calendar Table =

    VAR __Start_Date = DATE(YEAR(MIN('PB_traffic_trend'[Date])), 1, 1)
    VAR __End_Date = DATE(YEAR(MAX('PB_traffic_trend'[Date])), 12, 31)
    VAR __Range = CALENDAR(__Start_Date, __End_Date)
    VAR __Calendar_Table =
        ADDCOLUMNS(
            __Range,
            "Date Join", FORMAT( [Date], "mm/dd/yyyy"),
            "Year", YEAR([Date]),
            "Quarter", "Q" & FORMAT([Date], "Q, YYYY"),
            "Quarter Sort", FORMAT([Date], "YYYY-MM-Q"),  -- Modified for sorting
            "Month Number", MONTH([Date]),
            "Month Name", FORMAT([Date], "MMMM"),
            "Month Year", FORMAT([Date], "MMM, YYYY"),
            "Month Sort", FORMAT([Date], "YYYY-MM"),
            "Year to Date", FORMAT(DATE(YEAR([Date]), 1, 1), "MMM YYYY") & FORMAT([Date], " - MMM YYYY"),
            "Max Year", YEAR(MAX([Date])),
            "Max Month", MONTH(MAX([Date]))
        )
   
    RETURN
        __Calendar_Table
 
calendar_table.png
 
1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @Miguel_Rojo 

The problem is in the expressions for "Max Year" and "Max Month".

The MAX function must take a column reference from a physical table as its argument.

 

Did you want these to be the overall maximum year/month appearing in the Calendar Table?

If so you could write this (since the maximum date is already contained in the variable __End_Date )

 

"Max Year", YEAR( __End_Date ),
"Max Month", MONTH( __End_Date )

 

 

If that's not what you wanted, please post back to clarify what you wanted these values to be.

 

Regards

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

View solution in original post

2 REPLIES 2
OwenAuger
Super User
Super User

Hi @Miguel_Rojo 

The problem is in the expressions for "Max Year" and "Max Month".

The MAX function must take a column reference from a physical table as its argument.

 

Did you want these to be the overall maximum year/month appearing in the Calendar Table?

If so you could write this (since the maximum date is already contained in the variable __End_Date )

 

"Max Year", YEAR( __End_Date ),
"Max Month", MONTH( __End_Date )

 

 

If that's not what you wanted, please post back to clarify what you wanted these values to be.

 

Regards

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

Thanks Owen!!, you were right!, I was selecting an unexisting table using the MAX() function; I changed the code by:

    "Max Year", YEAR(MAXX(__Range, [Date])),
            "Max Month", MONTH(MAXX(__Range, [Date]))
 
and it worked!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.