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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
AmeenVanakar
Helper II
Helper II

Calendar Table with EOM. Need Help!

Hi,

Can you help in solving this error? Not sure how to solve this. Also need to verify the EOM column.

 

AmeenVanakar_0-1727705376913.png

 

DateTable =

VAR Startate = MIN(Customer_Data[BILL DATE])
VAR EndDate = MAX(Customer_Data[BILL DATE])
VAR DateTable =
ADDCOLUMNS(
    CALENDAR(Startate,EndDate),
    "Year", YEAR([Date]),
    "Quarter Name", FORMAT([Date], "\QQ"),
    "Quarter Number", QUARTER([Date]),
    "Month Name", FORMAT([Date], "MMM"),
    "Month Number", MONTH([Date]),
    "Month Year", FORMAT([Date], "MM YYYY"),
    "Month Year Sort", VALUE(FORMAT([Date], "YYYYMM")),
    "End Of Month", EOMONTH([Date],0),
)
RETURN
DateTable
 
1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

EOM looks fine.

 

You can't have a variable with the same name as a table or else it's ambiguous which one you're referring to. As Greg points out, it's common practice to use prefix variable names with underscores to prevent conflicts with table and reserved words. Like this:

 

DateTable =
VAR __Startate = MIN ( Customer_Data[BILL DATE] )
VAR __EndDate = MAX ( Customer_Data[BILL DATE] )
VAR __DateTable =
    ADDCOLUMNS (
        CALENDAR ( __Startate, __EndDate ),
        "Year", YEAR ( [Date] ),
        "Quarter Name", FORMAT ( [Date], "\QQ" ),
        "Quarter Number", QUARTER ( [Date] ),
        "Month Name", FORMAT ( [Date], "MMM" ),
        "Month Number", MONTH ( [Date] ),
        "Month Year", FORMAT ( [Date], "MM YYYY" ),
        "Month Year Sort", VALUE ( FORMAT ( [Date], "YYYYMM" ) ),
        "End Of Month", EOMONTH ( [Date], 0 )
    )
RETURN
    __DateTable

 

(Extra comma before the final ) removed.)

View solution in original post

3 REPLIES 3
AlexisOlson
Super User
Super User

EOM looks fine.

 

You can't have a variable with the same name as a table or else it's ambiguous which one you're referring to. As Greg points out, it's common practice to use prefix variable names with underscores to prevent conflicts with table and reserved words. Like this:

 

DateTable =
VAR __Startate = MIN ( Customer_Data[BILL DATE] )
VAR __EndDate = MAX ( Customer_Data[BILL DATE] )
VAR __DateTable =
    ADDCOLUMNS (
        CALENDAR ( __Startate, __EndDate ),
        "Year", YEAR ( [Date] ),
        "Quarter Name", FORMAT ( [Date], "\QQ" ),
        "Quarter Number", QUARTER ( [Date] ),
        "Month Name", FORMAT ( [Date], "MMM" ),
        "Month Number", MONTH ( [Date] ),
        "Month Year", FORMAT ( [Date], "MM YYYY" ),
        "Month Year Sort", VALUE ( FORMAT ( [Date], "YYYYMM" ) ),
        "End Of Month", EOMONTH ( [Date], 0 )
    )
RETURN
    __DateTable

 

(Extra comma before the final ) removed.)

Thanks @AlexisOlson & @Greg_Deckler this worked!

Greg_Deckler
Super User
Super User

@AmeenVanakar Put one or two underscore characters prior to your variable names and you will avoid these kinds of things.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.