Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
vikasshana
Creator II
Creator II

Selection of month has to show previous month sales

Hi,

I'm looking for a set analysis expression where if we select an year and month from filter it has to show previous year month sales. Below example data.

Date Market Sales
2/1/2024 IND 200
2/24/2024 NAM 100
1/1/2024 IND 100
1/21/2024 NAM 200
1/16/2024 AUS 600
12/15/2023 IND 300
9/16/2023 NAM 400
8/26/2023 AUS 500
4/13/2022 AUS 600
5/18/2022 IND 900
6/10/2022 NAM 700

 

Below example.

If I select 2024 from year filter and Feb from month it has to show 2024 Jan values in text objects

Feb 2024 Jan 2024
300 900

 

If I select 2024 from year filter and Jan from month it has to show 2023 Dec values.

Jan 2024 Dec 2023
900 300
2 Replies
marcus_sommer

Helpful for such scenarios is to create a continuous period-field within the calendar like:

Year * 12 + Month as RunningPeriod

and then within the expression something like:

sum({< RunningPeriod = {"$(=max(RunningPeriod)-1)"}>} Value) 

jonas_rezende
Specialist
Specialist

Hi, @vikasshana .

See if this solution helps you. I created it in QlikView and QlikSense, and the results were the same.

The script in Sense is exactly the same as what you see in the image.

Note that there is a configuration in the dimension of the tables.

 

View_Script.pngView_Sheet.pngView_Sheet_2_Table.pngf7c6c1d2-f556-4145-b44d-323d937a800a.PNG

9d20d676-a651-491a-87a3-2af719698be1.PNG

View_Expression_YearActual.pngView_Expression_YearPrevious.png

 

I hope I have helped!