Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Soul_mate
Contributor
Contributor

Recursive expression in Set Analysis

Hope you good, qlik-masters and enthusiasts!

I try to write some sort of recursive expression, and can't cope with that by myself.

What we got:

 - Year dimension Report_date (for simplicity I restrict it for only 5 years in example)

 - Fact measure Base_value with some values

 - Constant coefficient k = 0.74

What I try to make:

 - expression Calc_Value.

It should work like: Calc_Value = Base_Value - Sum_All_Previous_Calc_Values * k (see below).

I've tried use RangeSum(Above(Sum(Base_value) * k, 1, RowNo()) and all stuff around that expression, but its just doesn't work.

Also I saw post Can I make a recursive calculation, where each result is used in the following calculation? , but it's doesn't work for me as well.

Here my example:

recursive_expr.png

Because of variety of different data for selection in real, expression should work "on-the-fly" in front-end, not in script.

All the best, take care!

Labels (2)
1 Solution

Accepted Solutions
hic
Former Employee
Former Employee

It's possible to use recursive calls, but they only work in small charts. ("Small" meaning fewer than perhaps 100 rows.)

If you define a measure "Calc_value" as 

Base_value-RangeSum(Above(Calc_value,1,RowNo()))*k

then you can get 

Henric_Cronstrm_1-1649929355861.png

View solution in original post

2 Replies
hic
Former Employee
Former Employee

It's possible to use recursive calls, but they only work in small charts. ("Small" meaning fewer than perhaps 100 rows.)

If you define a measure "Calc_value" as 

Base_value-RangeSum(Above(Calc_value,1,RowNo()))*k

then you can get 

Henric_Cronstrm_1-1649929355861.png

Soul_mate
Contributor
Contributor
Author

Hello, Henric!

Thank you, pure class! 👍

One thing to add: for correct calculation untick option "Suppress zero-values".