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
Aukje
Helper I
Helper I

DAX: DATEADD, DATESYTD not working correctly

I am trying to accumulate values for the past year and using dateadd(dateytd) to do it.

However (after isolating the problem) my dateadd(dateytd) does not result in a calendar ending 2019-04-06, but in 2019-04-30 leading to faulty calculations.

 

I will add the formulae I used:

Table: YTD = DATESYTD('dimdate'[DateString];"30/6") results in a table from 190701-200406
 
Tables:
YTD LY (001) = DATEADD(DATESYTD('dimdate'[DateString];"30/6");-1;YEAR)
YTD LY (002) = DATESYTD(DATEADD('dimdate'[DateString];-1;YEAR);"30/6")
both result in a table from 180701-190430.
 
Does anyone recognize this problem and how to (in as simple manner if possible) limit YTD LY to 190406?
4 REPLIES 4
AilleryO
Memorable Member
Memorable Member

Hi @Aukje ,

 

First thing that strikes me, your date is named DateString, is it a real date value or a string (text) ?

You can use time Intelligence functions (DATEADD or YTD) only with dates (data type = Date or Date-Time).

 

Another thing, you seems to try to work with a date when you type "30/06",

which is not a date... which 30 of june do you want ? There is one each year as you noticed 😉

A date is day, month, and year (you must have the 3 parts).

 

This is not really solving your problem but might be a good start.

A Year to Date should look like this, I don't know what your 30/06 is standing for, filter ?

Sales YTD This Year = CALCULATE(TOTALYTD([Total Sales];MyCalendar[DateKey]))

Hope this help

Hi!

Thank you for your input.

 

1) It is named DateString, but converted to datevalue, so that should not cause the problem.

 

2) "30/06" is the last date of the year (to have a year from july through end of june). In my understanding I should explicitly NOT submit a year in this scenario, the last day of the year, EACH year is 30/06. It is an optional setting to change the inherit datelogic in PowerBi from 0101-1231 to 0701-0630.

 

Hi,

 

For your fiscal year issue, the best is to add a column qith fiscal year in your Date Table, so makes things easier for your filters.

 

Have a look at :

https://community.powerbi.com/t5/Desktop/Creating-a-Fiscal-Year-amp-Fiscal-Quarter-in-a-DATE-calenda...

or

https://community.powerbi.com/t5/Desktop/Power-Query-Fiscal-Year-and-Quarter/td-p/383347

Should help you,

Thank you for your reply! I do actually have a column for fiscal year. The fiscal year 2018-2019 should still only accumulate to 2019-04-06 (and tomorrow to 2019-04-07) etc, so not really sure how to achieve that even with having a column for fiscal year 🙂

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.