Forum Discussion

delmayhan's avatar
delmayhan
Frequent Visitor
3 years ago
Solved

Dateadd in previous Year

Hi all,

i created a column of the current date = today()  and important to know today is 03/01/2023

What we do is taking a snapshot 10 days after each quarter. And from there on i create a column to see the previous quarter.

 

So with this formule i want to see the quarter of the previous year only i see now blank values. The Dateadd functions doesn't work for previous year. If i change the formule in -1 day than i does work. And if i change it into -10 days than is doenst work anymore because it is in the previous year.  I read only that the dateadd function only work for date values when the excist in the datetable. I wondering how does it still work when i have a current date of today() and the formule still work if i add +3 Months when there is no date data because i am revering to the current date and that is only today. How can this work for in the previous year?

 

 

 

  • tamerj1's avatar
    tamerj1
    3 years ago

    delmayhan 
    Please try 

    Date of previous quarter = 
    VAR CurrentDate = 'Issue snapshot'[Current Date]
    VAR AdjustedDate = CurrentDate - 10
    VAR Days = DAY ( AdjustedDate )
    VAR PreviousDate = EOMONTH ( AdjustedDate, - 4 ) 
    RETURN
        PreviousDate + Days

4 Replies

    • delmayhan's avatar
      delmayhan
      Frequent Visitor

      Hi tamerj1 i expect the result ; Current date = Today() (03-01-2023 -10 days) = 24-12-2023 That is Q4 and then -1 quarter = Q3 So i Expect dates from Q3. Like 24-09-2022

       

      You can test it yourself creating a column of today and then the above DAX formule, i expect data in the year 2022 but i get blank values back.

       

       

       

      • tamerj1's avatar
        tamerj1
        Community Champion

        delmayhan 
        Please try 

        Date of previous quarter = 
        VAR CurrentDate = 'Issue snapshot'[Current Date]
        VAR AdjustedDate = CurrentDate - 10
        VAR Days = DAY ( AdjustedDate )
        VAR PreviousDate = EOMONTH ( AdjustedDate, - 4 ) 
        RETURN
            PreviousDate + Days