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.
fredericvillemi
Contributor III

Add the frequency in every listbox by script

Hi,

i'm trying to use some vbscript in Qlikview and i feel the model is quite difficult.

What i would like to do :

i want to open a document, list all the listboxes only and add the "Frequency in percent" to all of them.

I can't even find how to have an easy list of all listboxes in the document..

can you help me ?

Thanks

Tags (2)
1 Solution

Accepted Solutions
danielrozental
Honored Contributor II

Re: Add the frequency in every listbox by script

Try something like this

sub abc()

    for j= 0 to ActiveDocument.NoOfSheets - 1

        set s=ActiveDocument.Sheets(j)

        lboxes=s.GetListBoxes

        for i=lbound(lboxes) to ubound(lboxes)

             set box=lboxes(i).GetProperties

             box.Layout.ShowFrequency = true

             box.Layout.FrequencyInPercent = true

             lboxes(i).SetProperties box

        next

    next

end sub

4 Replies
danielrozental
Honored Contributor II

Re: Add the frequency in every listbox by script

Try something like this

sub abc()

    for j= 0 to ActiveDocument.NoOfSheets - 1

        set s=ActiveDocument.Sheets(j)

        lboxes=s.GetListBoxes

        for i=lbound(lboxes) to ubound(lboxes)

             set box=lboxes(i).GetProperties

             box.Layout.ShowFrequency = true

             box.Layout.FrequencyInPercent = true

             lboxes(i).SetProperties box

        next

    next

end sub

fredericvillemi
Contributor III

Re: Add the frequency in every listbox by script

that's excellent ! Thanks, very nice example.

And just one more thing : if i wanted to add expressions to my listbox, what is the syntax ?

addExpression doesn't seem to work with listboxes .. and properties.expressions.add seems not good ...

thanks

danielrozental
Honored Contributor II

Re: Add the frequency in every listbox by script

It was a hard one, took me a bit

    Set lst = b.GetSheetObject("LB03")

    Set c = lst.GetProperties.Expressions

    c.Add

    Set x = c.Item(c.Count - 1)

    x.Data.ExpressionData.Definition.v = "sum(SalesAmount*2)"

fredericvillemi
Contributor III

Re: Add the frequency in every listbox by script

great !

scripting is sometimes quite tricky but so powerful !

thanks Daniel

Community Browser