Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
umesh-umeshshukla
Contributor
Contributor

Comparing Current Month and Previous Month Sales

I have a bar chart consists of two bars for current month and previous month. The filter pane contains list of month-year like below table. The need is  to change the bar graph as per the selection in filter pane. For example, if I select Oct-2019, chart shows Oct-2019 and Sep-2019. if June-2019, then June -2019 and May 2019 and so on. Kindly assist.

Month-YearSales
Jan-20181000
Feb-20182000
Mar-20183000
Apr-20184000
May-20185000
Jun-20186000
Jul-20187000
Aug-20188000
Sep-20189000
Oct-201810000
Nov-201811000
Dec-201812000
Labels (2)
5 Replies
yogiachilleos
Contributor III
Contributor III

Howdy Umesh!

I like to build my calendars with an SortID attached to each major dimension that is text based or non-numeric (Month-Year, MonthName, DayOfWeek) [NOTE: If you've kept these numeric or used a dual() or some other sort of sorting system you can skip step 1 and go straight to step 2].

Step 1:

Month-Year2:

Load Month-Year

Resident Calendar

Order by Date Descending;

 

Left Join (Calendar)  // BECAREFUL - FOR WHATEVER REASON SOME VERSIONS OF QLIK WILL DISTINCT THE LEFT TABLE AS WELL, IF THIS HAPPENS SIMPLY DISTINCT THIS TABLE WITHOUT THE LEFT JOIN AND THEN LEFT JOIN IN A 3 STEP.

Load Distinct Month-Year

RowNo() as Month-Year_ID

Resident Month-Year2;

Drop Table Month-Year2;

 

Step 2:

Now in your chart you can use this equation:

Sum({1<[Month-Year_Sort] = {">=$(=(min([Month-Year_Sort])-1))<=$(=(min([Month-Year_Sort])))"}>}Sales)

The 1 gives us global data while the min[Month-Year_Sort]-1 gives you 1 month-year behind and the last min[Month-Year_Sort] gives you the cap which is your selection.

 

Hope this helps!

Kind regards,

Yogi Achilleos

Vegar
MVP
MVP

there are many ways to solve this issue, see attached gif animation and attached qvf for a way to do it.

5f7618d9-51f6-4be8-891b-e544d631b8d3.gif

Sameer9585
Creator II
Creator II

sum({<[Month-Year]={"<=$(=max(Month([Month-Year]))) >=$(=max(Month([Month-Year]))-2)"}>}Sales)
Vegar
MVP
MVP

@Sameer9585 your solution will only work within a single single year, selecting January 2019 will not return the data of December 2018.