Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

subin6600
Contributor III

Macro for setting load order for Fields Displayed in Table Box

Hi QlikViewer's,

I have a table box which is populated by a macro using the field selections a user wants. But the order of the fields displayed would be in the alphabetical order. i.e., I have two 4 fields.

NameAgeRegionMobile

Subin

25India9900
George26USA8899
Thomas28China7898

So, a user selects, Name & Age as the fields to be displayed - first selection on Name & then on Age

then both the fields would be displayed as below,

AgeName
25Subin
26George
28Thomas

As you see the above order, the fields are displayed in Alphabetical order. How can we achieve to get the load order. i.e., First Name field should be shown and then Age Field.

Regards,

Subin

Tags (2)
5 Replies
MVP & Luminary
MVP & Luminary

Re: Macro for setting load order for Fields Displayed in Table Box

If you want build the tablebox with a user-defined field-order you will need to store the selected values into a variable, something like:

varFieldOrder = '$(varFieldOrder)' & getfieldselections(YourFieldListbox, '|') & '|' &

then you could loop through these variable. But you will need some more logic to clear the variable after creating the tablebox and handle any errors. Easier could be to create such field-order by the tablebox in steps - first step: tablebox wille be created with the first field, second/third ... step will be to append field after field.

THe easiest way would be the user adjust the tablebox by drag 'n drop ...

- Marcus

subin6600
Contributor III

Re: Macro for setting load order for Fields Displayed in Table Box

Hi Marcus, I got your idea of storing the user selected fields in a variable. But how can I loop it to be visible to the users in a table box?

MVP & Luminary
MVP & Luminary

Re: Macro for setting load order for Fields Displayed in Table Box

You could use inside the vbs the split() function with the delimiter "|" to create an array through which you could loop.

- Marcus

subin6600
Contributor III

Re: Macro for setting load order for Fields Displayed in Table Box

Hi Marcus, When tried to get the getFieldSelections with the field, the values gets sorted again in alphabetical order.

MVP & Luminary
MVP & Luminary

Re: Macro for setting load order for Fields Displayed in Table Box

It was meant for a step by step selection and each single selection will be concatenated to the variable-value. Will be several field-values selected at once then there won't be any possibilty to track a order - it will be ordered alphabetically.

- Marcus