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

auto generate value using script

Hi all,

I am facing a problem in script level.

Which is i need to create auto generate value using script.

my example is

Item NoItem idDateValuevalue2
201310101/01/20170100
201310102/01/20170100
201310103/01/2017100100
201310104/01/20170100
201310105/01/20179090
201310106/01/2017090
201310201/01/20170200
201310202/01/2017200200
201310203/01/20170200
201310204/01/2017170170
201310205/01/20170170

please see my table i have 3 dimension which is item no , item id and date,

and also a measure which name is value i need like value2 measure  using script.

If you have any solution then please suggest me.

Thanks and regards

Swarnendu

11 Replies
YoussefBelloum
Champion
Champion

Hi,

what is the rules to calculate the Value 2 ?

swarnendu
Creator II
Creator II
Author

i used like this but its not working properly.

If(Item_no<>peek(Item_no) and Item_Id<>peek(Item_Id) and Date<>peek(Date),Value,Peek(Value)) as Value,

I need to generate the value filed  like value 2 field.

YoussefBelloum
Champion
Champion

your script is working fine here, the Peek works fine, it will always gives you the ELSE part which is the Peek(Value) because the condition is never met, Item No is always the same on the table you gave

swarnendu
Creator II
Creator II
Author

I know this problem but have you any idea how i can do it?

if you have any idea then please share.

Regards

swarnendu

YoussefBelloum
Champion
Champion

your calculation rules for Value2 field is simply wrong..

Try to define correct rules that can be applied to your data

swarnendu
Creator II
Creator II
Author

any suggestion ?

YoussefBelloum
Champion
Champion

I really can't tell you how to calculate your field..

but the only peek that make sense here is the Peek(Date), because there are some Dates presents on differents lines for different Item_id's.

But the question is how did you calculate the values present on the VALUE2 column ??

qliksus
Specialist II
Specialist II

Maybe something like the below

A1:
load

ItemNo,
Itemid, Date, Value , if(Peek(Itemid)=Itemid and Value=0, Peek(Value),Value) as Values

Resident A
order by ItemNo,Itemid,Date
;

A2:
load

ItemNo,
Itemid, Date, Value , if(Peek(Itemid)=Itemid and Values=0, Peek(Valuesfinal),Values) as Valuesfinal

Resident A1
order by ItemNo,Itemid,Date desc
;


DROP Table A,A1 ;

swarnendu
Creator II
Creator II
Author

Can you please share your .qvw file