Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
vikasshana
Creator III
Creator III

How to create a cumulative value.

Hi,

I've the below data in my app.

Table:
Load Date(Date#(Date,'MM/DD/YYYY')) as Date, Sales Inline [
Date, Sales

11/26/2020, 400 

11/26/2021, 300
12/26/2021, 100
1/1/2022, 200
];

In the front end I want to load only data from previous year until current year previous month. I'm using the below expressions

Dimension: Date(monthstart(aggr(only({<Date = {">=$(=Date(Yearstart(today(),-1)))<=$(=Date(MonthEnd(today(),-1)))"}>}Date),Date)),'YYYY-MM')

Expression: RangeSum(Above(Sum(Sales),0,RowNo()))

Output:

Date Value
2021-11 300
2021-12 400
2022-01 600

 

Required Output

Date Value
2021-11 700
2021-12 800
2022-01 1000

 

@PrashantSangle 

6 Replies
BrunPierre
Partner - Master II
Partner - Master II

@vikasshana Maybe like this

Dimension: Date(Date,'YYYY-MM')

Expression: Sum({<Date={">=$(=AddMonths(max(Date),-11))"}>}Aggr(RangeSum(Above(Sum({<Date=>}Sales),0,11)),Date))

 

vikasshana
Creator III
Creator III
Author

I've tried your solution, but still the same

vikasshana_0-1661842213582.png

 

BrunPierre
Partner - Master II
Partner - Master II

With the same sample date, this is the result. Could be the date format.

peter_brown_1-1661845099930.png

 

vikasshana
Creator III
Creator III
Author

I'm using the below sample code where I'm changing the date format, but still the same result

Table:
Load Date(Date#(Date,'MM/DD/YYYY')) as Date, Sales Inline [
Date, Sales
11/26/2020, 400 
11/26/2021, 300
12/26/2021, 100
1/1/2022, 200
];

BrunPierre
Partner - Master II
Partner - Master II

Sum({<Date={">=$(=AddMonths(max(Today()),-11))"}>}Aggr(RangeSum(Above(Sum({<Date=>}Sales),0,11)),Date))

vikasshana
Creator III
Creator III
Author

Thanks for that @BrunPierre , this expression is working with the sample data but when I use the same expression in my main application it is not working.