Playing with SAMEPERIODLASTYEAR and TOTALYTD functions
Let´s play with time intelligence DAX functions.
There is a table with two columns - timestamp and some numerical value.
At the beginning we will simply use the matrix visual and show the values in time.
And now? Maybe it would be nice to see the value year ago. That means we need this measure:
- Year before = CALCULATE(SUM(my_values[Values]);SAMEPERIODLASTYEAR(my_values[Date]);ALL(my_values))
So for each period we see the value year ago.
So there are some values for this and for previous year. But what´s the difference in percents? It is the division only.
- Year to year % difference = DIVIDE(SUM(my_values[Values])-[Year before];[Year before])
From the beginning of the year
Compare the beginning of this year with the beginning of last year
Do you want to know, if the YTD values for this year are better or worse compared to last year? Then simply combine both above mentioned values:
- YTD Year to year difference = [Year to date]-[Year to date last year]