Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

values from field to array by macro

Hi all!

i have simple table with fields: country, sale, cost

now i need to fill arrow (My_array with data from field sale:  My_array = ActiveDocument.GetField ("Sale") 

and then i want calculate new arrow data in macro, example:  

for i=0 to My_arraycount

My_array_new = My_array + 10

next i

and finaly add new field to my table which contante My_array_new

is it possible in QV such opertiotion?

Tags (1)
4 Replies
Not applicable

Re: values from field to array by macro

Why You want to do it by macro?

Why don't You just use above() function?

Not applicable

Re: values from field to array by macro

Hi!

I need try to do it by macros for another task.that is why this example is simple. in my real task i try to solve this:

1. rank customers by sale with some expression  main think: the most bigger customers those get 50% of total sale - rank "A", from 50%-80% - rank "B", from 80%-95% - rank "C", after 95% - rank "D". I use order by Sale desc field to get this.

2. rank customers by profit. I mean (sale / cost -1)  main think: the most bigger customers by (sale / cost -1) expression get 30% sale - rank "3", from 30%-70% - rank "2", after 70% - rank "1". I use order by (sale / cost -1) desc field to get this.

now i need join 2 rank in 1. it will be like:  A3, A2, A1, B3, B2 .... and s.o.

my problem is sorting: if i change sorting field, i lose my rank. that is why i thinking about macro

Not applicable

Re: values from field to array by macro

i found how load data from field to array

sub ABC

     set val=ActiveDocument.Fields("Sale").GetSelectedValues

     for i=0 to val.Count-1

         val.Item(i).Number = val.Item(i).Number+10

     next

msgbox(val.Item(0).Number)

end sub

now how add field with this new data?

Not applicable

Re: values from field to array by macro

solve by using macro and variables

Community Browser