Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Highlighted
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
Highlighted
Partner
Partner

Copy Cycle Group

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
Highlighted
Partner
Partner

Copy Cycle Group

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

Highlighted
Not applicable

Copy Cycle Group

This is very useful. Thanks Darius!

Highlighted
Not applicable

Copy Cycle Group

Exteremely useful!

Highlighted
Partner
Partner

Copy Cycle Group

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

Highlighted
Not applicable

Re: Copy Cycle Group

Hi Darius,

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

Highlighted
NickP_DF
New Contributor III

Re: Copy Cycle Group

Excellent solution Darius,

you make me gain a lot of time!

Thank you!

N.