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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Sasha
Helper III
Helper III

Why DATEADD results appear in a different month

Hi,

I've calculated the following measure:

Sales_Previous_Q = CALCULATE(DIVIDE(SUM(Data[Sales]),SUM(Data[Units])),DATEADD(Dates[Date_Key],-3,MONTH))
The thing is that when I put months on a table a long with the measure, I get the results on the months for shich (-3) refers to.
For example: if my data refers to Dec-Feb, the measure will calculate for Sep-Nov. I would expect to see the results in Dec-Feb as the measure is calculated compring to them. But I see them in Sep-Nov. What am I missing?
3 REPLIES 3
tex628
Community Champion
Community Champion

DATEADD moves the actual daterange a specific interval. So if you have a matrix with a column dimension of month, you are essentially placing a month filter on that specific cell. When you apply DATEADD to the measure calculated in that cell it moves the range the specified amount. 

So with no dateadd:

Jan-19Feb-19
Sales in janSales in feb


With dateadd -2 months:

Jan-19Feb-19
Sales in novSales in dec


If you want to display previous quarter, you need to make sure that the date table contains only the current quarter before you apply the dateadd to the column.

My advice is to do something like:
ALL(datetable),
Year = YEAR(TODAY())
Quarter = QUARTER(TODAY()),
DATEADD(datetable[dates],-3, MONTH)





Connect on LinkedIn

Hi,

in my example I see the sales under thier respective month. So if  current month is Jan I see previous month (Dec) under Dec, whereas I'd expected it to be shown under Jan as you said.

tex628
Community Champion
Community Champion

That sounds like you the issue is related to which dimension you are using in your table. 
The month column that you are using as the column dimension, is it from your sales table or your date table?


Connect on LinkedIn

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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