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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
hemantsingh
Helper V
Helper V

Comparing YTD of three years on a line chart

Hi there,

 

        I am trying to find out the YTD of last two years separately so that i can find out the trend in sales over the years in respective months. My sales table has transaction starting from 01-01-2013 till 31-08-2017. I have calculated the YTD of current year i.e 2017 till August. I am still scratching my head to find out a way to calculate YTD for last 2 years separately  i.e for 2016 & 2015.

    Kindly find below my Current_year_YTD Measure.

 

Current_year_YTD = if(min(datetable(date) <=calculate(max(sales(date)),all(sales)),                                     

                          calculate([sales_measure],filter(all(datetable(date)),datetable(date)<=max(datetable(date)),blank())

 

Note -- > 

 ** I have a dedicated date table that starts at 01-01-2013 & ends at 31-12-2018

** Sales_Measure is the measure that calculates the sum of sales 

 

  Any ideas how can i calculate the YTD of last years???

 

Regards,

Hemant

 

3 REPLIES 3
Greg_Deckler
Super User
Super User

Curious why you are not using TOTALYTD?

 

https://msdn.microsoft.com/en-us/library/ee634400.aspx

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler

 

   I tried using it total ytd before posting here but the result i am getting is good to see in matrix visual for all the years. I need to do more calcuation for which i need separate YTD's.

 

 

     Any more guesses,how can i calculate the ytd for three different years separately???

 

Regards

Hemant

How about creating a TOTALYTD measure, then using the parallelperiod to calculate the two years before it, like so:

 

YTD Current Year = TOTALYTD(Table[Column];'Date'[Date])

YTD Last Year = CALCULATE([YTD Current Year];PARALLELPERIOD('Date'[Date];-12;MONTH))

YTD Two Years Back = CALCULATE([YTD Current Year];PARALLELPERIOD('Date'[Date];-24;MONTH))

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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