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
vishwanathans
Helper II
Helper II

DATEADD error - Help me how to fix

Hi Experts,

 

Can somebody be able to guide me how to fix this issue,

 

vishwanathans_0-1603210614941.png

 

My dax code : 

Last MTD Cost = CALCULATE(SUM('Financial Data'[Cost]),DATESMTD(DATEADD('Financial Data'[Period name],-1,MONTH)))
 
Thanks in Advance.
 
Srinivasan Vishwanathan

 

3 REPLIES 3
amitchandak
Super User
Super User

@vishwanathans , I all such cases you should use a date table, Joined with date of your table

 

Last MTD Cost = CALCULATE(SUM('Financial Data'[Cost]),DATESMTD(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 :radacad sqlbi My Video Series Appreciate your Kudos.

 

Please provide your feedback comments and advice for new videos
Tutorial Series Dax Vs SQL Direct Query PBI Tips
Appreciate your Kudos.

@amitchandak  Hi, I tried this dax code. But Last MTD is not calculating properly. Last MTD value computing entire cost column.

vishwanathans_0-1603284312973.pngvishwanathans_1-1603284331940.png

 Can you please help me to sort this out.

 

Thanks for your help.

 

Thanks

Srini

Hi @vishwanathans 

 

What visualization do you put the measure in? Do you have any slicer or filter or something like rows/columns in a table/matrix to let the measure know what date should be used to calculate the value? Can you please provide some sample data or sample pbix as well as the expected result so that I can understand the error more clearly? Remember to remove the sensive information in the sample file. Thanks.

 

Best regards,

Jing

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.