Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

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
Honored Contributor II

Re: Macro to set field value

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

Re: Macro to set field value

Sure...

Like this simple while example:

myVariable = 1

while <TABLE.END OF RECORDS>

    fieldName = myVariable;

    myVariable = myVariable + 1;

end while

giakoum
Honored Contributor II

Re: Macro to set field value

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

Re: Macro to set field value

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
Honored Contributor II

Re: Macro to set field value

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

Not applicable

Re: Macro to set field value

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
Honored Contributor II

Re: Macro to set field value

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

Not applicable

Re: Macro to set field value

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
Honored Contributor II

Re: Macro to set field value

last question :

what determines how many qty clusters you have?

Community Browser