Forum Discussion

Tidous972's avatar
Tidous972
Frequent Visitor
5 years ago
Solved

TOTALYTD or CALCULATE

Dear All,

I have a Sales table ranging from 01/01/2019 to 08/31/2021 and I would like to compare the total sales but of course from January to August for each year. Can I use TOTALYTD.
Thanks for your help.
Regards

 

  • Hi Tidous972 

     

    Try these measures:

     

    For this year:

    TotalYTD = TOTALYTD(sum('Table'[Value]),'Table'[Date])
     
    For last Year:
    TotalLYTD = TOTALYTD(sum('Table'[Value]),SAMEPERIODLASTYEAR('Table'[Date]))
     
    For Year 2019 :
    Total2LYTD = TOTALYTD(sum('Table'[Value]),DATEADD('Table'[Date], -2, year))
     
    My data:
    DateValue
    31-Jan-19100
    28-Feb-19200
    31-Mar-19300
    30-Apr-19400
    31-May-19500
    30-Jun-19600
    31-Jul-19700
    31-Aug-19800
    30-Sep-19900
    31-Oct-191000
    30-Nov-191100
    31-Dec-191200
    31-Jan-201300
    29-Feb-201400
    31-Mar-201500
    30-Apr-201600
    31-May-201700
    30-Jun-201800
    31-Jul-201900
    31-Aug-202000
    30-Sep-202100
    31-Oct-202200
    30-Nov-202300
    31-Dec-202400
    31-Jan-212500
    28-Feb-212600
    31-Mar-212700
    30-Apr-212800
    31-May-212900
    30-Jun-213000
    31-Jul-213100
    31-Aug-213200
    output:
     

     


     

     

    If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

    Appreciate your Kudos!!

     

10 Replies

  • Tidous972 Hi Tidous972,

    It depends on your data because there are many ways of getting YTD sales based on data. please share sample data if possible.

    • Tidous972's avatar
      Tidous972
      Frequent Visitor
      Spoiler
      Spoiler
       

      Hi Colacan,

      Thank you for your answer. I dont know how to share the .pbix file.

  • Hi Tidous972 

     

    Try these measures:

     

    For this year:

    TotalYTD = TOTALYTD(sum('Table'[Value]),'Table'[Date])
     
    For last Year:
    TotalLYTD = TOTALYTD(sum('Table'[Value]),SAMEPERIODLASTYEAR('Table'[Date]))
     
    For Year 2019 :
    Total2LYTD = TOTALYTD(sum('Table'[Value]),DATEADD('Table'[Date], -2, year))
     
    My data:
    DateValue
    31-Jan-19100
    28-Feb-19200
    31-Mar-19300
    30-Apr-19400
    31-May-19500
    30-Jun-19600
    31-Jul-19700
    31-Aug-19800
    30-Sep-19900
    31-Oct-191000
    30-Nov-191100
    31-Dec-191200
    31-Jan-201300
    29-Feb-201400
    31-Mar-201500
    30-Apr-201600
    31-May-201700
    30-Jun-201800
    31-Jul-201900
    31-Aug-202000
    30-Sep-202100
    31-Oct-202200
    30-Nov-202300
    31-Dec-202400
    31-Jan-212500
    28-Feb-212600
    31-Mar-212700
    30-Apr-212800
    31-May-212900
    30-Jun-213000
    31-Jul-213100
    31-Aug-213200
    output:
     

     


     

     

    If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

    Appreciate your Kudos!!

     
    • Tidous972's avatar
      Tidous972
      Frequent Visitor

      Hi VahidDM

      It's Ok for the current year (01/31/21 to 08/31/21) but it's wrong for the previous years, the formulas don't work. For the last year and for 2019, i have the total of sales of the year and not the total of the same period of 2021 i.e January to August. (01/31/20 to 08/31/20 and 01/21/19 to 08/31/19). 

      Thanks for your help.

      • VahidDM's avatar
        VahidDM
        Icon for Super User rankSuper User

        Hi Tidous972 '

         

        Do you want to include value of January in the calculation? IF yes, based on my sample data those values from Measures are correct.

         

         Appreciate your Kudos!!