Forum Discussion

HBALAMURUGAN's avatar
HBALAMURUGAN
Frequent Visitor
3 years ago
Solved

Custom YTD

I want to create custom Year To date.
I am currently using the query Calculate(Sum(value),DATEADD(Date,-1,Year))  and this calculation is -365 days.

I want to give the start date as (Start of the date of the previous year )and end date as ((current day)-365) using my calendar lookup table for the above specified scenario.
Please help me with the query.

  • Calculate(Sum(value),DATESBETWEEN(Dates[Date],Date(Year(Today())-1,1,1),Today()-365))

6 Replies

  • v-yalanwu-msft's avatar
    v-yalanwu-msft
    Community Support

    Hi, HBALAMURUGAN ;

    You could create a measure as follow:

    TotalYTD1 = TOTALYTD(SUM(Invoices[Total]), Dates[Date], ALL(Dates), "06/30")

    if you want to change other date, could modify  "6/30" to another date.

    or try to use EDATE() funtion.

    EDATE function (DAX) - DAX | Microsoft Learn

    measure =
    CALCULATE ( SUM ( 'table'[value] ), EDATE ( 'table'[date], -12 ) )
    

    if not right, can you share a simple data and the result what you want to output?


    Best Regards,
    Community Support Team _ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • wdx223_Daniel's avatar
    wdx223_Daniel
    Community Champion

    Calculate(Sum(value),DATESBETWEEN(Dates[Date],Date(Year(Today())-1,1,1),Today()-365))

    • HBALAMURUGAN's avatar
      HBALAMURUGAN
      Frequent Visitor

      Thank you very much for your response, This is working great.

  • v-yalanwu-msft's avatar
    v-yalanwu-msft
    Community Support

    Hi, HBALAMURUGAN ;

    Is your problem solved?  If so, kindly mark the proper reply as a solution to help others having the similar issue and close the case. If not, let me know and I'll try to help you further.


    Best Regards,
    Community Support Team _ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • HBALAMURUGAN's avatar
      HBALAMURUGAN
      Frequent Visitor

      The answer is helping me to specify the start date of the year to date.However, I need to also specvify the end date for the YTD. Looking forward to have your support in this regard.

  • v-yalanwu-msft's avatar
    v-yalanwu-msft
    Community Support

    Hi, HBALAMURUGAN ;

    Can you give an example? I don't quite understand, could provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

    Solved: How to upload PBI in Community - Microsoft Power BI Community


    Best Regards,
    Community Support Team _ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.