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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
cristianml
Post Prodigy
Post Prodigy

DATEADD Issue

Hi,

 I have an issue with DATEADD function. When I add -1 month it shows blank values.

 

_Rev Previous = CALCULATE([_Rev Actual],DATEADD('Calendar'[Date],-1,MONTH))

cristianml_0-1649568403867.png

 

When I use 0 works fine. But I need to use -1, -3 months , etc

_Rev Previous = CALCULATE([_Rev Actual],DATEADD('Calendar'[Date],0,MONTH))

cristianml_1-1649568489206.png

Any idea ?

 

Thanks!

 

 

2 ACCEPTED SOLUTIONS
OwenAuger
Super User
Super User

Hi @cristianml 

It looks like 'Calendar' might not be marked as a date table.

https://docs.microsoft.com/en-us/power-bi/transform-model/desktop-date-tables#setting-your-own-date-...

If that's not the problem, please post back and a sanitised PBIX would be useful to help diagnose.

 

Regards

Owen


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

View solution in original post

Thanks for posting back! 🙂

The issue appears to be that the 'Calendar' tables is based on distinct dates from Actuals and Backlog, which appears to be one date per month.

A Date table in Power BI must include all dates in the range from earliest to latest date present, even if some of those dates don't exist in fact tables.

It's also good practice to include full financial years (and therefore full months), otherwise some time intelligence functions may give unexpected results.

 

Here is a proposed definition of Calendar that would cover complete Sep-Aug years, and you should be able to mark as a date table:

 

Calendar =
VAR FYStartMonth =
	9 // FY is Sep to Aug 
VAR Offset =
    MOD ( 13 - FYStartMonth, 12 )
VAR MinDate =
    MIN ( MIN ( Actuals[Date] ), MIN ( Backlog[Date] ) )
VAR MaxDate =
    MAX ( MAX ( Actuals[Date] ), MAX ( Backlog[Date] ) )
VAR MinDateFY =
    YEAR ( EOMONTH ( MinDate, Offset ) )
VAR MaxDateFY =
    YEAR ( EOMONTH ( MaxDate, Offset ) )
VAR CalendarStart =
    EDATE ( DATE ( MinDateFY, 1, 1 ), - Offset )
VAR CalendarEnd =
    EOMONTH ( DATE ( MAXDateFY, 12, 1 ), - Offset )
VAR CalendarFinal =
    CALENDAR ( CalendarStart, CalendarEnd )
RETURN
    CalendarFinal

 

There are other ways of building the Date table, e.g. Power Query scripts or tools like Bravo.

 

Hopefully that helps!

Regards,

Owen


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

View solution in original post

3 REPLIES 3
OwenAuger
Super User
Super User

Hi @cristianml 

It looks like 'Calendar' might not be marked as a date table.

https://docs.microsoft.com/en-us/power-bi/transform-model/desktop-date-tables#setting-your-own-date-...

If that's not the problem, please post back and a sanitised PBIX would be useful to help diagnose.

 

Regards

Owen


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

hI @OwenAuger ,

 

It doesn't allow me to mark as a date table. It says date column can't have gaps in dates. But I don't see gaps there:

cristianml_0-1649569483211.png

 

Thanks for posting back! 🙂

The issue appears to be that the 'Calendar' tables is based on distinct dates from Actuals and Backlog, which appears to be one date per month.

A Date table in Power BI must include all dates in the range from earliest to latest date present, even if some of those dates don't exist in fact tables.

It's also good practice to include full financial years (and therefore full months), otherwise some time intelligence functions may give unexpected results.

 

Here is a proposed definition of Calendar that would cover complete Sep-Aug years, and you should be able to mark as a date table:

 

Calendar =
VAR FYStartMonth =
	9 // FY is Sep to Aug 
VAR Offset =
    MOD ( 13 - FYStartMonth, 12 )
VAR MinDate =
    MIN ( MIN ( Actuals[Date] ), MIN ( Backlog[Date] ) )
VAR MaxDate =
    MAX ( MAX ( Actuals[Date] ), MAX ( Backlog[Date] ) )
VAR MinDateFY =
    YEAR ( EOMONTH ( MinDate, Offset ) )
VAR MaxDateFY =
    YEAR ( EOMONTH ( MaxDate, Offset ) )
VAR CalendarStart =
    EDATE ( DATE ( MinDateFY, 1, 1 ), - Offset )
VAR CalendarEnd =
    EOMONTH ( DATE ( MAXDateFY, 12, 1 ), - Offset )
VAR CalendarFinal =
    CALENDAR ( CalendarStart, CalendarEnd )
RETURN
    CalendarFinal

 

There are other ways of building the Date table, e.g. Power Query scripts or tools like Bravo.

 

Hopefully that helps!

Regards,

Owen


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

Helpful resources

Announcements
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.