Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
vikasshana
Creator II
Creator II

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
Master
Master

@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 II
Creator II
Author

I've tried your solution, but still the same

vikasshana_0-1661842213582.png

 

BrunPierre
Master
Master

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

peter_brown_1-1661845099930.png

 

vikasshana
Creator II
Creator II
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
Master
Master

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

vikasshana
Creator II
Creator II
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.