Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
UserID2626
Partner - Creator III
Partner - Creator III

MOM calculation in Qliksense Script

Hi,

I need a calculate and add as a separate column in a table by using load statement.

Product:

Load

XX_date,

Product_type,

Amount

from table1;

 

Final:

Load

XX_date,

Product_type,

(MOM_formula) as MOM //here if Month is march,the value should be difference of march&February and so on

from table1;

 

Drop table table1;

 

Please  help how to give MOM formula in Script

 

Thanks 🙂

 

Labels (4)
1 Solution

Accepted Solutions
kaanerisen
Creator III
Creator III

My bad 🙂 How about this?

Load
Month,
Value as Sum,
Value-Previous(Value) as PreMonthDiff;
load
Date(MonthStart(Date),'MM-YYYY') as Month,
Sum(Value) as Value
Inline [
Date,Value
03.01.2018,50
18.01.2018,60
19.02.2018,23
14.03.2018,21
23.03.2018,37
]
Group by Date(MonthStart(Date),'MM-YYYY');

 

Untitled.png

View solution in original post

3 Replies
kaanerisen
Creator III
Creator III

Hi vivethakumar,

Yoou can use RangeSum function to make it work.

Sample Script:

Load
Month,
Value as Sum,
RangeSum(Value,peek(RunningSum)) as RunningSum;
load
Date(MonthStart(Date),'MM-YYYY') as Month,
Sum(Value) as Value
Inline [
Date,Value
03.01.2018,50
18.01.2018,60
19.02.2018,23
14.03.2018,21
23.03.2018,37
]
Group by Date(MonthStart(Date),'MM-YYYY');

 

Untitled.png

Hope it helps..

UserID2626
Partner - Creator III
Partner - Creator III
Author

Thanks Kaanerisen,

you have added the values, but i need difference of current vs previous month formula in script.

kaanerisen
Creator III
Creator III

My bad 🙂 How about this?

Load
Month,
Value as Sum,
Value-Previous(Value) as PreMonthDiff;
load
Date(MonthStart(Date),'MM-YYYY') as Month,
Sum(Value) as Value
Inline [
Date,Value
03.01.2018,50
18.01.2018,60
19.02.2018,23
14.03.2018,21
23.03.2018,37
]
Group by Date(MonthStart(Date),'MM-YYYY');

 

Untitled.png