Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Now Live: Qlik Sense SaaS Simplified Authoring – Analytics Creation for Everyone: READ DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Copy Cycle Group

Hello

I have to create 6 cycle groups for a large multi-way table. The need to contain the same 40 variables in the same order. Is there a way to copy one cycle group to make the others, rather than having to make them all manually, it's a bit of a pain!

Thanks.

1 Solution

Accepted Solutions
d_pranskus
Partner - Creator III
Partner - Creator III

You can use macro for that:

Sub CopyGroup (SrcName, DstName)
    Set SrcGrp = ActiveDocument.GetGroup(SrcName)
    Set SrcProps = SrcGrp.GetProperties
    Set DstGrp = ActiveDocument.CreateGroup(DstName)
    Set DstProps = DstGrp.GetProperties
    DstProps.FieldDefs.CopyFrom SrcProps.FieldDefs
    DstProps.IsCyclic = SrcProps.IsCyclic
    DstProps.Labels = SrcProps.Labels
    DstProps.Present = SrcProps.Present
    DstProps.SortCriterias.CopyFrom SrcProps.SortCriterias
    DstGrp.SetProperties DstProps
End Sub

Calling:

Sub DoCopying
    CopyGroup "ExistingGroupName", "NewGroupName"
End Sub

Cheers

Darius

View solution in original post

6 Replies
d_pranskus
Partner - Creator III
Partner - Creator III

You can use macro for that:

Sub CopyGroup (SrcName, DstName)
    Set SrcGrp = ActiveDocument.GetGroup(SrcName)
    Set SrcProps = SrcGrp.GetProperties
    Set DstGrp = ActiveDocument.CreateGroup(DstName)
    Set DstProps = DstGrp.GetProperties
    DstProps.FieldDefs.CopyFrom SrcProps.FieldDefs
    DstProps.IsCyclic = SrcProps.IsCyclic
    DstProps.Labels = SrcProps.Labels
    DstProps.Present = SrcProps.Present
    DstProps.SortCriterias.CopyFrom SrcProps.SortCriterias
    DstGrp.SetProperties DstProps
End Sub

Calling:

Sub DoCopying
    CopyGroup "ExistingGroupName", "NewGroupName"
End Sub

Cheers

Darius

Not applicable
Author

This is very useful. Thanks Darius!

Not applicable
Author

Exteremely useful!

d_pranskus
Partner - Creator III
Partner - Creator III

New version of the script. If destination group exists, it replaces it's contents.

Sub CopyGroup (SrcName, DstName)

    Set SrcGrp = ActiveDocument.GetGroup(SrcName)

    Set SrcProps = SrcGrp.GetProperties

          Set DstGrp = ActiveDocument.GetGroup(DstName)

          If DstGrp Is Nothing Then

              Set DstGrp = ActiveDocument.CreateGroup(DstName)

           Else

              Set DstProps = DstGrp.GetProperties

              for i = 1 to DstProps.FieldDefs.Count

                              DstGrp.RemoveField 0

              Next

          End If

    Set DstProps = DstGrp.GetProperties

    DstProps.FieldDefs.CopyFrom SrcProps.FieldDefs

    DstProps.IsCyclic = SrcProps.IsCyclic

    DstProps.Labels = SrcProps.Labels

    DstProps.Present = SrcProps.Present

    DstProps.SortCriterias.CopyFrom SrcProps.SortCriterias

    DstGrp.SetProperties DstProps

End Sub

' Calling

Sub DoCopying

    CopyGroup "grp1", "grp2"

End Sub

Cheers Darius

Not applicable
Author

Hi Darius,

This was so useful I registered just to say thank you.  Thank You!

NickP_DF
Creator
Creator

Excellent solution Darius,

you make me gain a lot of time!

Thank you!

N.