Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Steve84
Contributor
Contributor

YoY diff formula

Hello everyone,

I am new to the community. I would like to pose a question regarding YoY difference in Sales.

My data are organized in periods such as Jan-2018, Feb-2018... until Mar-2020.

I have also create a filter with this Dimension (MonthYear).

My question is how to calculate automatically the YoY difference in Sales, when someone chooses for example Feb-2020 in the filter. I have used the following formulas that do not show to work..

sum([Sales])-(sum({$< Year={$(=only(Year)-1)} >}[Sales]) , which calculates Sales of Feb-2020 in filter minus Sales of previous Year (2019).

sum([Sales])-sum({$< Year={$(=only(Year)-1)}, Month={$(=only(Month))}>}([Sales]) which calculates Sales of the selected period in filter (Feb-2020), minus Sales of previous Year and same month (Feb 2019).

I am not sure why these formulas do not work..

Any ideas/help from anyone?

Labels (1)
2 Replies
siddharth_s3
Partner - Creator II
Partner - Creator II

Hi Steve,

How about you try this:

1) Create a line chart

2) Use MonthYear as your dimension

3) Sum(Sales) - BEFORE(Sum(Sales)) as your expression.

4) You can do the same in a pivot but here you have to use the keyword ABOVE instead of BEFORE.

Steve84
Contributor
Contributor
Author

Hi Siddarth,

Thanks for your quick response.

I would prefer to suggest me a formula as I have many dimensions (not only MonthYear) and measures instead of Sales that I would like to report.

Stavros