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
what exactly are you trying to achieve? is it to get the column with previous month values like:
and so on??? or just what was the previous month?
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))
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)