Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

ratio of this month and last month

Hello,

I have following table and want to have a ratio between current month and last month, how about the expression ?

YearMonthSales
20141100
20142220
20143300
20144120
20145400

Is my below expression correct ?

Sum(sales)-sum({<Month=(Month-1)>} sales)

Expecting view is like below.

Snap6.gif

Thanks&Regards,

Jessica

11 Replies
sasiparupudi1
Master III
Master III

I think to get accurate results during the year change, you need to do this in the script.

Table1:

load Year,Month,Sales,Year&Num(Month,'00') as YearMonth inline

[

Year,Month,Sales

2014,1,100

2014,2,220

2014,3,300

2014,4,120

2014,5,400

];

NoConcatenate

LOAD Year,Month,Sales,YearMonth,

if(Date#(Peek('YearMonth'),'YYYYMM')=Date(addmonths(Date#(YearMonth,'YYYYMM'),-1),'YYYYMM'),Peek('Sales'),0) as PreviousSales

resident Table1

order by YearMonth;

drop table Table1;

In the chart object

use the expression sum(Sales)-sum(PreviousSales)

HTH

Sas

sasiparupudi1
Master III
Master III

hi

did you manage to solve the issue?

Sasi