Qlik Community

Ask a Question

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

Announcements
Do More with Qlik - for Beginners and Beyond, Topic: Qlik Replicate on January 21, 2PM EST. REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro: Loop over all groups?

Does anyone of you know how to loop over all groups using a macro?

Normally I would count the items in the array I've got through "getgroups" and do a "for...next...loop" over them, but somehow I can't figure out how to count the existing groups (cyclic and drilldown) in the document.The normal count-method doesn't seem to work here.

Thanks for your help in advance...

3 Replies
Not applicable

Hi

a bit strange, also ubound/lbound do not work. maybe better solutions exist than this one



sub groupmembers()
grouparray=activedocument.getgroups
for i = 0 to 5
on error resume next
set gp=grouparray(i).GetProperties
if err <> 0 then
msgbox("err " & i)
exit for
end if
next
end sub


Regards

Jürg

Partner
Partner

you could use a while not isnull statement instead of for...next

Partner
Partner

try this one:

-> gives you groups and containing fields

Sub Get_Groups()

    groups = ActiveDocument.GetGroups

    j=0

    For each item in groups

        set gp = groups(j).GetProperties

        set gd = groups(j).GetDescription

        set vars = gp.FieldDefs

        for i = 0 to vars.Count-1

            set fld = vars.Item(i)

            msgbox("Group: " & gd.Name & " - field " & i+1 & " is " & fld.Name)

        Next

        j=j+1

    next

End Sub