Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
neha_shirsath
Specialist
Specialist

Need Help In Expression

Hello Community,

I need your help for below.

I'm attaching the excel,

DateABC
1
50
45
816
25248820
35451823

In this,

Column C  for Date 1st is calculate- (Value(811)+ 1st Date A value(50) - 1st date B value (45))= 816

                  for Date 2nd is- (Column C value for 1st Date(816)+2nd date A(52) - 2nd Date B Value(48))=820

                  for Date 3rd is- (Column C value for 2ndt Date(820)+3rd date A(54) - 3rd Date B Value(51))=823

and so on..

Please help how to write expression for this scenario.

I'm attaching the excel.

Thanks In Advance.

-Neha

6 Replies
Not applicable

Hi,

Use the peek() function
LOAD .... A+B+peek('C') as C ...

Fabrice

hic
Former Employee
Former Employee

Small correction:

     A+B+Peek('C')

will evaluate to NULL on the first row, since Peek('C') is undefined. Use RangeSum instead:

     RangeSum(A,B,Peek('C'))

HIC

neha_shirsath
Specialist
Specialist
Author

Thanks For you valuable reply,

But I can't do this on script level as my A & B value coming from 2 different qvd's.

This is only sample excel i have created to get an idea.

Can we do this on expression level to calculate C column?

Thanks,

Neha

qlikpahadi07
Specialist
Specialist

I think you can join/concatenate the QVD and perform the same with resident which HIC has mentioned

Not applicable

You will have to put A and B into one single table (use JOIN).

Sort also this table because the peek('C') function returns the value of the preceding row (so you will prefer it returns the value of the previous date)

As Henric suggested, yes use Rangesum(), ifnot the NULL will propagate.

Fabrice


neha_shirsath
Specialist
Specialist
Author

Hello,

Thanks to all.

HIC Post help me to find solution,

i have not join the qvd's but tried it in expression itself and it works correctly.

Below is the expression for help-

sum(Value) + rangeSum(above(sum(A),0,RowNo()))-rangeSum(above(B),0,RowNo()))

Thanks

Neha