cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

DATEADD & PREVIOUSMONTH not working

I'm hoping I'm just making a simple mistake here. I created a sample file and was able to reproduce the issue i'm having in my working model. For some reason, both the DATEADD and PREVIOUSMONTH are not working as expected. I have a date table. I created a calc column in both my data table & date table called date key that is just the date as an integer. This is what i created the relationship on. Each time i try and get previous month numbers in a measure it returns the total sum of all months. Here is the sample file SAMPLE FILE

3 REPLIES 3
Abduvali Established Member
Established Member

Re: DATEADD & PREVIOUSMONTH not working

Hi @Caitlin_Knox,

 

what exactly are you trying to achieve? is it to get the column with previous month values like: 

1 jan

2 feb

3 mar

4 apr

and so on??? or just what was the previous month?

 

Re: DATEADD & PREVIOUSMONTH not working

My end goal is to create a measure where the current month total can be compared against the previous month in a kpi visual. This seems easy enough, but i got hung up on creating the previous month total. Here's my DAX if its helpful

I've triple checked the syntax, so I think it might have somethign to do with my relationship? Or how I've created the datekey. I've used this strategy in the past, however, with no weird issues.

 

 

PreviousMonthMRC = CALCULATE(SUM(Sheet1[MRC]),DATEADD('Date'[Date],-1,MONTH))

2017-11-09_9-34-58.png

Abduvali Established Member
Established Member

Re: DATEADD & PREVIOUSMONTH not working

There is PreviousMonth function in DAX but for some reason, it doesn't work on my side but you can give it a shot.

I found a way around it so give it a try:

 

Previous Month Sales = CALCULATE(SUM('Sheet4 (2)'[Sales]),MONTH ('Sheet4 (2)'[Date]  ) = MONTH ( TODAY () )-1)