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
Caitlin_Knox
Advocate III
Advocate III

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
Skilled Sharer
Skilled Sharer

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?

 

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

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)

 

 

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.