Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro to set field value

Hello fellows,

I need to write a macro that set values to field in a table.

Anyone can help me?

Thank you

11 Replies
giakoum
Partner - Master II
Partner - Master II

Could you please clarify this a bit? What do you mean by setting values to a field in a table? internal table or table chart (straight table)?

Thank you.

Not applicable
Author

Sure...

Like this simple while example:

myVariable = 1

while <TABLE.END OF RECORDS>

    fieldName = myVariable;

    myVariable = myVariable + 1;

end while

giakoum
Partner - Master II
Partner - Master II

This can be done during reload easily.

But it looks like you are trying to set a field value with a macro after the reload.

If yes, then this could maybe only work with an inputfield.

Even simpler, why not make an appropriate expression in a chart?

I really need more details in order to answer that correcty.

Ioannis

Not applicable
Author

Ok Ioannis,

In my analysis case, i need to set value with macro code.

Like this.

1. Sum total value of a field

2. Incremental sum of this field until this sum is equal to 25% of total, then set value with 1 (cluster 1)

3. Sum next values until sum is equal 25% of total, then set value with 2 (cluster 2).

Take a look in a basic example.

#ValueCluster
19001
28101
38001
47802
57202
66202
75003
85003
93203
103003
112203
122004
131254
14604
15404
16104
Total6905
25% total1726,25
giakoum
Partner - Master II
Partner - Master II

sorry for asking so many questions, but I would do it as in the attached example. No use of macro.

Not applicable
Author

Greate Ionannis,

But in my example, i used 4 cluster. In real case, it would be flexible, like 2, 3, 4 or more cluster.

In this case, I think it should be using macro, correct?

giakoum
Partner - Master II
Partner - Master II

Sorry, cannot follow. if the criteria is the 25% of total sum, how could you end up with more than 4 clusters?

Not applicable
Author

if qty clusters is 2, then the criteira is 50%

if qty clusters is 3, then the criteria is 33%

if qry clusters is 4, then the criteria is 25%

if qty clusters is 5, then the criteria is 16%

and so on... 😉

giakoum
Partner - Master II
Partner - Master II

last question :

what determines how many qty clusters you have?