Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
ThanksHello to everybody
I need to have a calculate columns starting from 2 columns
A | B | C | n |
---|---|---|---|
0 | 100 | 100 | 1 |
20 | 0 | 120 | 2 |
30 | 0 | 150 | 3 |
10 | 0 | 160 | 4 |
10 | 0 | 170 | 5 |
if A=0
C=B
if A <> 0 C=A+C(n-1)
I have tried an Expression like this
if(A=0, B,rangesum( A,above(C,0,RowNo()) ) )
but it doesn't works.
Thanks
Oronzo
Hi Oronzo,
Your expression
if A <> 0 C=A+C(n-1)
Can use this if A <> 0 then C=A/(2-n) ?
If like this it easy to calculate value.
Regards,
Sokkorn Cheav
My goal is to have the sum of A with the previous value of C ( C(n-1)..)
C=A+C(n-1)
Thanks
Not sure if this fulfills all your requirements, but with the given sample, this results in the expected values for C:
=aggr( rangesum(above( A,0,RowNo()))+ rangesum(above( B,0,RowNo())),n)
Hello
Thank you for your answer, but is not exactly what I would to obtain
In attachement I have put an example
With this expression
if(A=0,B,aggr( rangesum(above( A,0,RowNo()))+ rangesum(above( B,0,RowNo())),n))
regard
Yes, I already thought you would like to reset the overall value on zero values in field A, i.e. you have multiple segements that you want to sum up separately, right?
Can this be done in the script? Would be much easier then, or do you need to be sensitive to selections?
Thank you for your answer,
But since I use QlikView just need to know how to load the script.
Many Thanks
Oronzo
In the script, I would do it like this:
Result:
LOAD n, A, B,
if(A=0, B, A+ peek(C)) as C
resident YourTable order by n;
drop table YourTable;
where YourTable is the Input table already loaded with fields n,A,B.
Regards,
Stefan
Thanks for your answer, I must analyze well my data
Regards
Oronzo