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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Jérôme5625
Creator
Creator

Cumulative cost on table QLIK

Hello, I want to create a simple table in QLIK. I am starting to get the hang of QLIK, but I can't seem to do what I want, even though it seems very simple to me. I want to create a table with the years and the cost, and a third column with the cumulative cost of the previous three years for the year in the row. I have a field [Date comptable_ ANNEE] and a field Total_des_couts for the cost.

I have entered the dimension  [Date comptable_ ANNEE] and the measure sum(Total_des_couts).

However, when I fill in the third column to get the cumulative calculation, it doesn't work because it only takes the result for the current year...

I've tried several syntaxes 

- Sum(
{<
[Date comptable_ ANNEE] = {">=$(=Max([Date comptable_ ANNEE])-3) <=$(=Max([Date comptable_ ANNEE])-1)"}
>} Total_des_couts
)

 

but I can't get it to work, the result is 0. Here's what I want in the attachment: If anyone has a solution without creating new fields in a script, that would be great... Thanks in advance.

 

Labels (2)
4 Replies
MatheusC
Specialist II
Specialist II

in your example the last line is 360, but I believe it is 460 according to the above values.

So try this:

IF(RowNo(TOTAL)=1,'', RangeSum(Above(Sum(Total_des_couts), 1 )))

- Regards

Did you find a solution to your question? Mark the solution as accepted and if you found it useful, press the like button!
Jérôme5625
Creator
Creator
Author

Is there any other solution than the above function as it depends on the year sorting?
thanks for advance

 

Chanty4u
MVP
MVP

Try this 

RangeSum(

    Above(Sum(Total_des_couts), 0, 3)

 

)

MatheusC
Specialist II
Specialist II

That's why I look for the accumulation outside of the modifier, so in this case, see it like this.

max(aggr(RangeSum(Above(Sum(Total_des_couts), 1 ,RowNo())),([Date comptable_ ANNEE],(=Sum(Total_des_couts),Cresc))))

Did you find a solution to your question? Mark the solution as accepted and if you found it useful, press the like button!