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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
burna
Frequent Visitor

YTD comparison of different years

I want to calculate , YTD sales for 2015,2016,2017 .Can anyone tell me how to write a DAX query for that  ? I have the data for gross earnings per month  for each of the above year 

1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey,

 

in this example pbix file there is an example. Have a look at the report page "YTD TimeIntelligence". Within the table "FactWithDates" there is this measure "YTD Amount"

 

YTD Amount = 
CALCULATE(
	TOTALYTD(SUM(FactWithDates[Amount]),'Calendar'[Date])
)

Please be aware that this measure assumes that there is a separate Calendar table, that is related to the fact table. If you don't have a separate calendar table you should consider to create one, as most of the DAX Time Intelligence functions in DAX just work if there is no missing date value in the column used as parameter.

 

This link also provides additional examples regarding time relevant calculations

http://www.daxpatterns.com/time-patterns/

 

Hope this gets you started

Regards



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

2 REPLIES 2
TomMartens
Super User
Super User

Hey,

 

in this example pbix file there is an example. Have a look at the report page "YTD TimeIntelligence". Within the table "FactWithDates" there is this measure "YTD Amount"

 

YTD Amount = 
CALCULATE(
	TOTALYTD(SUM(FactWithDates[Amount]),'Calendar'[Date])
)

Please be aware that this measure assumes that there is a separate Calendar table, that is related to the fact table. If you don't have a separate calendar table you should consider to create one, as most of the DAX Time Intelligence functions in DAX just work if there is no missing date value in the column used as parameter.

 

This link also provides additional examples regarding time relevant calculations

http://www.daxpatterns.com/time-patterns/

 

Hope this gets you started

Regards



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Thanks ,that was helpful .Got my desired result 🙂

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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

Users online (228)