Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Tidous972
Frequent Visitor

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

 

1 ACCEPTED SOLUTION
VahidDM
Super User
Super User

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:
 
VahidDM_1-1632877609852.png

 


 

 

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

Appreciate your Kudos!!

 

View solution in original post

10 REPLIES 10
VahidDM
Super User
Super User

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:
 
VahidDM_1-1632877609852.png

 


 

 

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

Appreciate your Kudos!!

 

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.

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!!

 

 

 

HI VadidDM,

Yes of course, I want to include the values of January. I have copied your formula exactly but it returns me the total sales for the year and not the partial sales from January to August for 2019 and 2020.Thank you for taking the time to help me.

@Tidous972 

 

Can you share a sample of your data in a table format (to be able to copy and past that)?

I VahidDM,

To follow up on my previous post, I found the origin of the error and is due to the relationship with the Date table of my model. When I delete the relation between Date table and the tables of Sales, the TotalYTD and Total2YTD formulas works, otherwise the visuals concerning the previous years are empty when the relationship is on. Do you have an idea.

Hi VahidDM,

I realized that you have to use the same table (TableSales'[Value]),SAMEPERIODLASTYEAR('TableSales'[Date])and not the calendar table, but this time the visual is empty. I don't understand why.

 

 

colacan
Resolver II
Resolver II

@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.

Spoiler
Spoiler
 

Hi Colacan,

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

Sales samples.JPG

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.