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 September 15. Request your voucher.

Reply
Anonymous
Not applicable

DATEADD function?

Hello  -  Simple problem I think, but not having any luck with DATEADD  (assuming that is what I need to use). 

 

The values in these visuals are correct values....just one month ahead of where they need to be.    In other words, the April data should really be the March data, the March data should be the February data, etc.   

 

This is the current measure I am using.    Tried to add DATEADD into but got an error.      Any guidance on how to fix would be appreciated!

 

Measure 5 = CALCULATE(SUM(Flu_Snapshots[Actual Value]),ENDOFMONTH(Flu_Snapshots[As Of Date])
 
monthbehind.png
4 REPLIES 4
amitchandak
Super User
Super User

@Anonymous 

Both formula's like this should work with a date calendar

last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,MONTH))

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

 Hi Amit, Yes, I always use date tables.

 

In this case, the data is not coming form a sales table.   It is coming from a "snapshot" exported from our ERP system.   The snapshot is an aggregated value...in this case for a KPI called "last period"   (that is what I have the filter set to).   

 

This filter aggregates to the last period, based on what value you set the "as of date" to.     I am using the endofmonth function to grab the last date of each period.   The only issue is that the values are mis-matched with the months  (values are one month ahead of the dates).    The April value should be the March value, March should be Feb, etc.  

 

Measure 5 = CALCULATE(SUM(Flu_Snapshots[Actual Value]),ENDOFMONTH(Flu_Snapshots[As Of Date]))
edhans
Super User
Super User

DATEADD() works over columns, not scalar values. So the following will not work:

    DATEADD(
        date(2020,1,1),
        1,
        MONTH
    )

The first part of the DATEADD() function needs to be a column of dates. But you didn't show how you were using it or what your error was, so not sure if that is the issue.

 

How to get good help fast. Help us help you.
How to Get Your Question Answered Quickly
How to provide sample data in the Power BI Forum



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

I do have a date table. And I think as you pointed out, the scalar value is the issue.

 

The formula referenced "snapshots" coming out of our ERP system (I hate working with snapshot data!).    In any case, there is a filtere applied that is an aggretation done in the ERP system.   It is called "All Revenue Last Period".  

 

I use the "endofmonth" function because I want to retrieve the last values of the prior months...these numbers are not regular sales numbers that I could pull from the sales table  (as Amit's formula would do).    These specific totals have been reconciled by accounting and yes, they are scalar.  

 

Again, the formula derives the correct numbers, just not on the correct months.  

 

Measure 5 = CALCULATE(SUM(Flu_Snapshots[Actual Value]),ENDOFMONTH(Flu_Snapshots[As Of Date]))*-1

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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