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

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

Reply
Anonymous
Not applicable

Issue with MonthYear using it as a date in a measure to do prior year calculate

Measure is:

 

Units PY1 = CALCULATE (

      [Units],

      DATEADD( DATESYTD ('Tablename'[MonthYear].[Date]), -1,YEAR) )

 

My MonthYear in Tablename has a format of Data Type = Date and format = mmmm yyyy

I have a date table with that format as well, but not sure if that matters.

 

The error message I get is:

 

"Column reference to 'MonthYear' in table 'Tablename' cannot be used with a variation 'Date' because it does not have any."

 

Also, my company does not allow me to put sample data online for reference.  So "Tablename" is not the real name, just for reference in this question.

10 REPLIES 10
Anonymous
Not applicable

I did not resolve this issue; I went another direction.

 

I have my data hierarchies off, and I do not use them.  I had a calendar table.  I was planning to try building a date yyyy-mm-01, but I because of another issue that there is no solution for yet in Power BI, I had to move to building the report in Excel.  I am not having the same issue with my dates with my model data when I tied it to Excel.  I appreciate your effort.

Anonymous
Not applicable

I did not resolve this issue; I went another direction.

 

I have my data hierarchies off, and I do not use them.  I had a calendar table.  I was planning to try building a date yyyy-mm-01, but I because of another issue that there is no solution for yet in Power BI, I had to move to building the report in Excel.  I am not having the same issue with my dates with my model data when I tied it to Excel.  I appreciate your effort.

Anonymous
Not applicable

I have a calendar (aka date table) as I mentioned in my first message, but I am still getting the error.

Use the date column from the calendar table for your DATEADD calculations, not the [MonthYear].[Date] column from 'Tablename' 

Anonymous
Not applicable

I changed the table to the calendar table within my equation.  My error is still the same.  Is it maybe and issue with the format of month/year being  mmmm yyyy?  I have used this formula before in another model but the month year format was month number then year.

The format is most likely not the issue. Time intelligence functions usually fail if the underlying date column is not contiguous and not covering.

Anonymous
Not applicable

I am going to try changing my date format to mm/yyyy (number month) to see if that works.

Anonymous
Not applicable

I reviewed a youtube video from Two Guys in a cube.  Double checked my date format to make sure the caalendar and tablename dates aligned, and they do now.  One thing I am wondering, I had to create a coloumn for MonthYear in Table name, so it is a calculated column.  I had month (name) and year in my source data and both are text format.  Power BI would not let me change the format type to date on those columns.  I am afraid this is what is causing my issues.

 

Add a fictional day to your calculated column - "yyyy-mm-01" . Then you can convert that to a date. 

lbendlin
Super User
Super User

Try to avoid using the built in date hierarchies. Instead, add a proper calendar table to your data model.  That will make the time intelligence functions work properly too.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors
Top Kudoed Authors