Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
campos_rsc
Contributor
Contributor

Previous year sales for the same weeks

Hi everyone,

I have a bit of a challenge with the following scenario:

Data set is aggregated at a WeekStart Level (lowest level) - I'm deriving the month and year from this date. The user wants to select Year and Month, let's say 2020 - May and see the Sales for last year - same weeks by Product. 

So if May 2020 has 5 weeks by WeekStart I would want to show the Sales for the same weeks previous year irrespective of the fact that one of the weeks might fall into June 2019. Remember that only one Year is always selected and Month has one or several months always selected and the final table is made of Product, Sales this Period and Sales Previous Year.

Hope it makes sense, any help would be greatly appreciated.

Thanks

Raz

1 Solution

Accepted Solutions
usamabinsadiq
Contributor III
Contributor III

Hi

Please see the result, I think you were looking for this:

Previous Year Sale for same weeks.jpg

Measure Expressions:

//Sales this Period
Sum({<Year={$(=max(Year))}>} Sales)

//Sales Previous Year
Sum({<Year={$(=max(Year)-1)},Week={"$(= '<=' & max(Week) & '>=' & min(Week) )"}>} Sales)

 

hope this helps,

 

Regards,

if my replay helped you then please press like button and do not forget to press the "Accept as Solution" button.

View solution in original post

4 Replies
usamabinsadiq
Contributor III
Contributor III

Hi Raz,

if you can provide some example data then I think I might be able to help with this.

if my replay helped you then please press like button and do not forget to press the "Accept as Solution" button.
campos_rsc
Contributor
Contributor
Author

Please find attached. 

So again, for the previous year I don't want the Week 18 to be included in the calculation when selecting May 2020.

Thanks

usamabinsadiq
Contributor III
Contributor III

Hi

Please see the result, I think you were looking for this:

Previous Year Sale for same weeks.jpg

Measure Expressions:

//Sales this Period
Sum({<Year={$(=max(Year))}>} Sales)

//Sales Previous Year
Sum({<Year={$(=max(Year)-1)},Week={"$(= '<=' & max(Week) & '>=' & min(Week) )"}>} Sales)

 

hope this helps,

 

Regards,

if my replay helped you then please press like button and do not forget to press the "Accept as Solution" button.
campos_rsc
Contributor
Contributor
Author

Perfect, works as expected.

Thank you, much appreciated.