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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
fredericvillemi
Specialist
Specialist

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

1 Solution

Accepted Solutions
danielrozental
Master II
Master II

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

View solution in original post

4 Replies
danielrozental
Master II
Master II

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
Specialist
Specialist
Author

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
Master II
Master II

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
Specialist
Specialist
Author

great !

scripting is sometimes quite tricky but so powerful !

thanks Daniel