Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
manoj217
Creator III
Creator III

pick field name into the variable

Hi All,

I have 5 fields in a table, those are field1, field2, field3, field4, field5  these are loaded in a order 1st column, 2nd column, 3rd column like that

for example :

i want to create a variable  vf1= if(sum(1stcolumn) > sum(2nd cloumn),1,0)

              actual                         vf1=if(sum(field1)>sum(field2),1,0)  like that  if i change the above condition 3rd column ,4th column

   dynamically it has to take the values field3 and field4 how can i acheive this

6 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

i don't understand your requirement. Do you want to create a collection of variables? What does "actual" mean here? What do you mean by changing the condition dynamically?

I suggest that you post a small sample document with some representative data and the table in question and a clear description of what you need with specific examples.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
manoj217
Creator III
Creator III
Author

in above example vf1= if(sum(1stcolumn) > sum(2nd cloumn),1,0)   

1st column means first field name in the table

2nd column means second field name in the table

if i have A,B,C,D are fields 

A=first field

B=second Field like that

vf1= if(sum(1stcolumn) > sum(2nd cloumn),1,0)  

                         A                         B

vf1= if(sum(2ndcolumn) > sum(3rd cloumn),1,0)  

                         B                              C

like that field names need to change dynamically based on 2nd column 3rd column fourth column like that

tresesco
MVP
MVP

May be you need parameterized variable (Qlikview Parameterised Variables). Try defining your variable like:

vf1 = if(sum($1) > sum($2),1,0)


and then pass field names while expanding the variable like:


$(vf1(Field2, Field3))            // you can change field names as and when required while calling it.

manoj217
Creator III
Creator III
Author

in future it may increase the fields A,B,C,D,E like that but it has to take first column means A only  last column means the updated value

manoj217
Creator III
Creator III
Author

but i want to change dynamically without  doing this

$(vf1(Field2, Field3))            // you can change field names as and when required while calling it.


dont want to change field names dynamically it has to take the updated values

jmartineze
Partner - Creator
Partner - Creator

Try this...

For i = 1 to NoOfRows('Table')

      set name = 'Dim$(i)';

      set '$(name)' = 'expression';

   Next i