Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
Modernize Your QlikView Deployment webinar, Nov. 3rd. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Luminary
Luminary

Count total groups in document

Hi,

I see this sample in API Guide:

groups = ActiveDocument.GetGroups

set gp = groups(0).GetProperties

vars = gp.Labels

msgbox vars(0)

I want to know the total of groups in a document to do a loop. I'm trying something like this:

groups = ActiveDocument.GetGroups

total = groups.Count

For i=0 to total-1

Set gp = groups(i).GetProperties

...

Next


But I don't how I can get the number of total groups in a QlikView document. I tried searching on API Guide but I didn't found anything.

Can anybody help me or know how I

1 Solution

Accepted Solutions
Highlighted
Partner
Partner

You can use Rob Wunderlich's Document Analyzer

View solution in original post

9 Replies
Highlighted
Partner
Partner

You can use Rob Wunderlich's Document Analyzer

View solution in original post

Highlighted

You can download the analyzer from here http://qlikviewcookbook.com/recipes/download-info/document-analyzer/

Best,

Sunny

Highlighted
Partner
Partner

here's one I found:

Macro: Loop over all groups?

Highlighted
Luminary
Luminary

Thanks sunindia! I check the analyzer and the following code works for me!

rem *** Extract groups from a Document object

Sub extractGroups(docObj)

    'Dim groups, gp, i, j, fields, field, groupName

    log "Extracting Groups"

    groups = docObj.GetGroups

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

        set gp = groups(i).GetProperties

        groupName = gp.Name

        If gp.IsCyclic Then groupType = "Cyclic" Else groupType = "Drill"

        set fields = gp.FieldDefs

        for j = 0 to fields.Count-1

                set fld = fields(j)

                groupsFile.WriteLine( _

                    csvQuote(groupName) _

                    & "," & csvQuote(groupType) _

                    & "," & csvQuote(fld.Name) _

                )

        next

    next

End Sub

Highlighted

I am glad it worked, but I think you should thank JPenuliar because he gave you the idea to use that, I just gave you the link to the place from where you can download it

Best,

Sunny

Highlighted
Luminary
Luminary

Thanks for your help Jonathan! It works for me!

Highlighted
Partner
Partner

No Worries Daniel, and Thanks to the points you awarded, I am now a Wizard.

Highlighted

Yay!! Congratulations Jonathan Penuliar

Best,

Sunny

Highlighted
Partner
Partner

Thank you sunindia