Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

daniel_garcia_m
New Contributor II

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
Valued Contributor III

Re: Count total groups in document

You can use Rob Wunderlich's Document Analyzer

9 Replies
jpenuliar
Valued Contributor III

Re: Count total groups in document

You can use Rob Wunderlich's Document Analyzer

Re: Count total groups in document

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

Best,

Sunny

jpenuliar
Valued Contributor III

Re: Count total groups in document

here's one I found:

Macro: Loop over all groups?

daniel_garcia_m
New Contributor II

Re: Count total groups in document

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

Re: Count total groups in document

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

daniel_garcia_m
New Contributor II

Re: Count total groups in document

Thanks for your help Jonathan! It works for me!

jpenuliar
Valued Contributor III

Re: Count total groups in document

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

Re: Count total groups in document

Yay!! Congratulations Jonathan Penuliar

Best,

Sunny

jpenuliar
Valued Contributor III

Re: Count total groups in document

Thank you sunindia

Community Browser