<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Auto Select From Cyclic Expression in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Auto-Select-From-Cyclic-Expression/m-p/149001#M504567</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Folks&lt;/P&gt;&lt;P&gt;I have a macro that allows me to select whatever dimension from a cyclic dimension for a chart and this works really well, I am now looking at doing the same for a cyclic expression but I'm not really sure where to start.&lt;/P&gt;&lt;P&gt;My Macro for the dimension is:&lt;/P&gt;&lt;P&gt;SET grp1 = ActiveDocument.GetGroup("StdListA")&lt;/P&gt;&lt;P&gt;WHILE grp1.GetActiveField.Name &amp;lt;&amp;gt; "DealAggName" DO&lt;/P&gt;&lt;P&gt;grp1.Cycle 1&lt;/P&gt;&lt;P&gt;LOOP&lt;/P&gt;&lt;P&gt;If anybody has any clues as to how I can do this I'd appreciate it.&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Jul 2009 21:08:26 GMT</pubDate>
    <dc:creator />
    <dc:date>2009-07-10T21:08:26Z</dc:date>
    <item>
      <title>Auto Select From Cyclic Expression</title>
      <link>https://community.qlik.com/t5/QlikView/Auto-Select-From-Cyclic-Expression/m-p/149001#M504567</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Folks&lt;/P&gt;&lt;P&gt;I have a macro that allows me to select whatever dimension from a cyclic dimension for a chart and this works really well, I am now looking at doing the same for a cyclic expression but I'm not really sure where to start.&lt;/P&gt;&lt;P&gt;My Macro for the dimension is:&lt;/P&gt;&lt;P&gt;SET grp1 = ActiveDocument.GetGroup("StdListA")&lt;/P&gt;&lt;P&gt;WHILE grp1.GetActiveField.Name &amp;lt;&amp;gt; "DealAggName" DO&lt;/P&gt;&lt;P&gt;grp1.Cycle 1&lt;/P&gt;&lt;P&gt;LOOP&lt;/P&gt;&lt;P&gt;If anybody has any clues as to how I can do this I'd appreciate it.&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Jul 2009 21:08:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Auto-Select-From-Cyclic-Expression/m-p/149001#M504567</guid>
      <dc:creator />
      <dc:date>2009-07-10T21:08:26Z</dc:date>
    </item>
    <item>
      <title>Auto Select From Cyclic Expression</title>
      <link>https://community.qlik.com/t5/QlikView/Auto-Select-From-Cyclic-Expression/m-p/149002#M504568</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nigel,&lt;/P&gt;&lt;P&gt;This may help - code to cycle through the expressions for a chart&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;&lt;BR /&gt;Sub CycleExpression&lt;BR /&gt;&lt;BR /&gt; set chart = ActiveDocument.GetSheetObject("CH01")&lt;BR /&gt; set cp = chart.GetProperties&lt;BR /&gt;&lt;BR /&gt; ' Get a count of the current expressions&lt;BR /&gt; iCount = cp.Expressions.Item(0).Count&lt;BR /&gt;&lt;BR /&gt; ' N.B. Item(0) in this case is the first Expression group - there may be more than one&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; ' Add a new Expression&lt;BR /&gt; cp.Expressions.Item(0).Add()&lt;BR /&gt; ' Copy from the first one&lt;BR /&gt; cp.Expressions.Item(0).Item(iCount).CopyFrom(cp.Expressions.Item(0).Item(0))&lt;BR /&gt; 'TempExpr.CopyFrom(cp.Expressions.Item(0).Item(0))&lt;BR /&gt; ' Loop Through and Copy from next one&lt;BR /&gt; for i = 0 to iCount-1&lt;BR /&gt;&lt;BR /&gt; cp.Expressions.Item(0).Item(i).CopyFrom(cp.Expressions.Item(0).Item(i+1))&lt;BR /&gt;&lt;BR /&gt; Next&lt;BR /&gt; ' Remove the last one&lt;BR /&gt; cp.Expressions.Item(0).RemoveAt(iCount)&lt;BR /&gt;&lt;BR /&gt; ' save back to the chart&lt;BR /&gt; chart.SetProperties cp&lt;BR /&gt;&lt;BR /&gt;End Sub&lt;BR /&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;You might want to do something like loop through the expressions and query the name using:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;&lt;BR /&gt;cp.Expressions.Item(0).Item(i).Data.ExpressionVisual.Label.v&lt;BR /&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;And then just swap with the one at postion 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stephen&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Jul 2009 22:49:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Auto-Select-From-Cyclic-Expression/m-p/149002#M504568</guid>
      <dc:creator>stephencredmond</dc:creator>
      <dc:date>2009-07-10T22:49:25Z</dc:date>
    </item>
    <item>
      <title>Auto Select From Cyclic Expression</title>
      <link>https://community.qlik.com/t5/QlikView/Auto-Select-From-Cyclic-Expression/m-p/149003#M504569</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Stephen&lt;/P&gt;&lt;P&gt;That's great, I think I can work with that, will try something &amp;amp; let you know.&lt;/P&gt;&lt;P&gt;Cheers &amp;amp; have a great weekend.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Jul 2009 22:59:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Auto-Select-From-Cyclic-Expression/m-p/149003#M504569</guid>
      <dc:creator />
      <dc:date>2009-07-10T22:59:30Z</dc:date>
    </item>
    <item>
      <title>Re: Auto Select From Cyclic Expression</title>
      <link>https://community.qlik.com/t5/QlikView/Auto-Select-From-Cyclic-Expression/m-p/149004#M504570</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;i implemented Nigels approach to set a cycle group by macro code. But his method steps thru all the cycle group elements causing all sheet objects to render over and over again until the right item is finally reached. This is not desirable so after some hefty elaboration with different API features i finally got a working solution. The macro needs two variables to be set. vMacroParam1 expects name of cycle group as string, vMacroParam2 expects name of group member to be selected. I have created a button with 3 Actions (set vMacroParam1 , set vMacroParam2 , trigger SetDimGroupSel) which works as expected.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sub SetDimGroupSel&lt;BR /&gt; ' fetch name of group to be selected ------------------&lt;BR /&gt; Dim strGrp&lt;BR /&gt; strGrp = ActiveDocument.Variables("vMacroParam1").GetContent().String&lt;BR /&gt; &lt;BR /&gt; ' set instance pointers&lt;BR /&gt; set grp = ActiveDocument.GetGroup(strGrp) 'returns pointer to Group instance&lt;BR /&gt; set grpProps = grp.GetProperties ' returns pointer to IGroupProperties instance&lt;BR /&gt; set fldDefs = grpProps.FieldDefs ' returns pointer to IArrayOfFieldDevEx instance&lt;BR /&gt; 'set fldItem0 = fldDefs.Item(0) ' returns pointer to IFieldDevEx instance&lt;BR /&gt; 'msgbox("Item0.Name = " &amp;amp; fldItem0.Name) &lt;BR /&gt; &lt;BR /&gt; ' fetch name of currently selected field&lt;BR /&gt; Dim strActiveField&lt;BR /&gt; strActiveField = grp.GetActiveField.Name&lt;BR /&gt; &lt;BR /&gt; ' fetch name of field to be selecetd ------------------&lt;BR /&gt; Dim strNewField&lt;BR /&gt; strNewField = ActiveDocument.Variables("vMacroParam2").GetContent().String&lt;BR /&gt; &lt;BR /&gt; 'msgbox("strActiveField = "&amp;amp;strActiveField)&lt;BR /&gt; 'msgbox("strNewField = "&amp;amp;strNewField)&lt;BR /&gt; &lt;BR /&gt; ' variable item name for loop&lt;BR /&gt; Dim fldName&lt;BR /&gt; 'msgbox("fldName = " &amp;amp; fldName)&lt;BR /&gt; &lt;BR /&gt; ' number of field items&lt;BR /&gt; Dim fldCount&lt;BR /&gt; fldCount = fldDefs.Count&lt;BR /&gt; 'msgbox(fldCount&amp;amp;" field items in group")&lt;BR /&gt; &lt;BR /&gt; If (true = grpProps.IsCyclic) then&lt;BR /&gt;&amp;nbsp; 'msgbox("IsCyclic = "&amp;amp;grpProps.IsCyclic)&lt;BR /&gt;&amp;nbsp; if (true = grpProps.Present) then&lt;BR /&gt;&amp;nbsp;&amp;nbsp; 'msgbox("Present = "&amp;amp;grpProps.Present)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; 'index pointers&lt;BR /&gt;&amp;nbsp;&amp;nbsp; Dim ixCurrent, ixNew, cycleSteps&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; 'loop throug all items of group to find the index positions of strActiveField and strNewField&lt;BR /&gt;&amp;nbsp;&amp;nbsp; for i=0 to fldCount-1 Step 1&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'msgbox("fetch name of item("&amp;amp; i &amp;amp;") for comparison")&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fldName = fldDefs.Item(i).Name&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'msgbox("fldName = " &amp;amp; fldName)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (fldName = strActiveField) then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ixCurrent = i&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end if&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (fldName = strNewField) then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ixNew = i&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end if&lt;BR /&gt;&amp;nbsp;&amp;nbsp; next&lt;BR /&gt;&amp;nbsp;&amp;nbsp; 'msgbox("ixCurrent = " &amp;amp; ixCurrent &amp;amp; " ixNew =" &amp;amp; ixNew )&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; 'derive number of cycle steps&lt;BR /&gt;&amp;nbsp;&amp;nbsp; cycleSteps = fldCount + (ixNew - ixCurrent)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; 'msgbox("cycleSteps = " &amp;amp; cycleSteps)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; 'cycle derived number of steps&lt;BR /&gt;&amp;nbsp;&amp;nbsp; grp.Cycle cycleSteps&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp; end if&lt;BR /&gt; end if&lt;BR /&gt; &lt;BR /&gt; 'msgbox("ActiveField = "&amp;amp;grp.GetActiveField.Name) &lt;BR /&gt;End Sub&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Sep 2014 14:35:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Auto-Select-From-Cyclic-Expression/m-p/149004#M504570</guid>
      <dc:creator>gerhard_jakubec</dc:creator>
      <dc:date>2014-09-10T14:35:03Z</dc:date>
    </item>
  </channel>
</rss>

