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
cdawidow
Helper III
Helper III

DATEADD error message for visuals

 

ERRORS.PNG

 

I created 2 measures, Current Year MTD Sales and LYMTD Sales.  

LYMTD Sales = CALCULATE([Total Sales],DATESMTD(DATEADD('ORDHDT01 (2)'[Fiscal Dates],-12,MONTH)))
MTD Sales = TOTALMTD([Total Sales],'ORDHDT01 (2)'[Fiscal Dates])
 
But I am now trying to put these measures in a basic visual but as I use the months from my fiscal dates field to showcase the changes over the months, I get this error message. Any ideas why?
 
4 REPLIES 4
Anonymous
Not applicable

All time-intel functions necessarily need a proper Date table. A proper date table has a column with dates in it which are continuous, unique and cover full years. Just create such a table and connect to your fact table. Everything will then work perfectly well. If you really want to create good and correct models, please structure your data as a star schema. Power BI has been designed to work with star schemas in the best possible way. You can even read this in the official documentation.
AntrikshSharma
Community Champion
Community Champion

Is this table ORDHDT01 (2) a calendar table with all the dates for whole calendar/fiscal year? Also if you are not slicing data by dates then also you will get the same error. Remove every field from the visual apart from the columns coming from the dates table.
amitchandak
Super User
Super User

@cdawidow , DATEADD need continuous dates. that is why always suggested to use date table with time intelligence.

example

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))
last MTD (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(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 :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-Y...


Appreciate your Kudos.

Greg_Deckler
Super User
Super User

@cdawidow - It's hard to say really without sample data. The time "intelligence" functions are so black box it's really tough to troubleshoot them when they don't work. You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...

 

Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.

Top Solution Authors