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: 
bharatkishore
Creator III
Creator III

Creating Group through Macro

Hello All,

                    I have generated a group with 4 fields like A,B,C,D.Now i want to create another group with same fields by using Macro function.Can any one help me how to do this.

                   I am attaching my qlikview file for ur better understanding.

1 Solution

Accepted Solutions
forte
Partner - Creator
Partner - Creator

Hi bharatkishore,

I think this macro example can be usefull,

sub copyGroup

Set gr = ActiveDocument.CreateGroup("GROUP2")

set gd = ActiveDocument.GetGroupDescription("GROUP1")


'Firstly we copy iscyclic property
gp = gr.GetProperties
gp.IsCyclic = gd.IsCyclic
gr.SetProperties gp

'Just add each field on GROUP1 TO GROUP2
set fdefs = gd.FieldDefs

for i = 0 to fdefs.Count-1

set fld = fdefs.Item(i)
gr.AddField fld.Name

next

end sub

Regars

View solution in original post

2 Replies
forte
Partner - Creator
Partner - Creator

Hi bharatkishore,

I think this macro example can be usefull,

sub copyGroup

Set gr = ActiveDocument.CreateGroup("GROUP2")

set gd = ActiveDocument.GetGroupDescription("GROUP1")


'Firstly we copy iscyclic property
gp = gr.GetProperties
gp.IsCyclic = gd.IsCyclic
gr.SetProperties gp

'Just add each field on GROUP1 TO GROUP2
set fdefs = gd.FieldDefs

for i = 0 to fdefs.Count-1

set fld = fdefs.Item(i)
gr.AddField fld.Name

next

end sub

Regars

bharatkishore
Creator III
Creator III
Author

Thanks Forte.