Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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
jpenuliar
Partner - Specialist III
Partner - Specialist III

You can use Rob Wunderlich's Document Analyzer

View solution in original post

9 Replies
jpenuliar
Partner - Specialist III
Partner - Specialist III

You can use Rob Wunderlich's Document Analyzer

sunny_talwar

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

Best,

Sunny

jpenuliar
Partner - Specialist III
Partner - Specialist III

here's one I found:

Macro: Loop over all groups?

Anonymous
Not applicable
Author

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

sunny_talwar

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

Anonymous
Not applicable
Author

Thanks for your help Jonathan! It works for me!

jpenuliar
Partner - Specialist III
Partner - Specialist III

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

sunny_talwar

Yay!! Congratulations Jonathan Penuliar

Best,

Sunny

jpenuliar
Partner - Specialist III
Partner - Specialist III

Thank you sunindia