<?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 Re: Macro looping through two fields. in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Macro-looping-through-two-fields/m-p/1597158#M595695</link>
    <description>&lt;P&gt;From a pure loop point of view you will need a second loop within the first one - it's completely the same logic just nesting one within the another. But I think it will be rather not useful in the end because the fields are in general independent of each other and only if each fieldvalue from field 1 has the same number of sub-values in field 2 and those values are also always the same such loop will work.&lt;/P&gt;&lt;P&gt;Therefore I think you need to loop through a table of both fields - within the following link is an example how it could be done: &lt;A href="https://community.qlik.com/t5/QlikView-App-Development/Export-to-CSV-with-quotation-marks/td-p/1138389" target="_blank" rel="noopener"&gt;Export-to-CSV-with-quotation-marks&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;</description>
    <pubDate>Fri, 28 Jun 2019 09:43:28 GMT</pubDate>
    <dc:creator>marcus_sommer</dc:creator>
    <dc:date>2019-06-28T09:43:28Z</dc:date>
    <item>
      <title>Macro looping through two fields.</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-looping-through-two-fields/m-p/1596987#M595694</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I have this requirement in macro explained below.&lt;/P&gt;&lt;P&gt;I have this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;Field 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Field 2&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;a&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;b&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;c&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;d&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;11&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Field 1 is the main field with satatic 4 values. Field 2 subfield of F1, each value in F1 has 11 elements in F2 .&lt;/P&gt;&lt;P&gt;The only thing i need to do is loop through F1 value A and loop in all F2 and then pass to the next element in F1 and so...&lt;/P&gt;&lt;P&gt;My code is this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Sub importantLoop
	
	set x=ActiveDocument.Fields("Field1").GetPossibleValues
	For u=0 to x.count-1
		ActiveDocument.Fields("Field1").Select x.item(u).Text
	next
	
End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but when i ran it, it olny select the first value in F1, 4 times (i need to add the second field)&lt;/P&gt;&lt;P&gt;any idea?. also, both F1 and F2 are string values.&lt;/P&gt;&lt;P&gt;Thanks in advanced.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 20:33:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-looping-through-two-fields/m-p/1596987#M595694</guid>
      <dc:creator>darkshadow91223</dc:creator>
      <dc:date>2024-11-16T20:33:47Z</dc:date>
    </item>
    <item>
      <title>Re: Macro looping through two fields.</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-looping-through-two-fields/m-p/1597158#M595695</link>
      <description>&lt;P&gt;From a pure loop point of view you will need a second loop within the first one - it's completely the same logic just nesting one within the another. But I think it will be rather not useful in the end because the fields are in general independent of each other and only if each fieldvalue from field 1 has the same number of sub-values in field 2 and those values are also always the same such loop will work.&lt;/P&gt;&lt;P&gt;Therefore I think you need to loop through a table of both fields - within the following link is an example how it could be done: &lt;A href="https://community.qlik.com/t5/QlikView-App-Development/Export-to-CSV-with-quotation-marks/td-p/1138389" target="_blank" rel="noopener"&gt;Export-to-CSV-with-quotation-marks&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jun 2019 09:43:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-looping-through-two-fields/m-p/1597158#M595695</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2019-06-28T09:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: Macro looping through two fields.</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-looping-through-two-fields/m-p/1597199#M595696</link>
      <description>&lt;P&gt;For &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;u&lt;/STRONG&gt;&lt;/FONT&gt;=0 to x.count-1&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;ActiveDocument.Fields("Field1").Select x.item(&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;i&lt;/FONT&gt;&lt;/STRONG&gt;).Text&lt;BR /&gt;next&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Correct:&lt;/P&gt;&lt;P&gt;For &lt;FONT color="#339966"&gt;&lt;STRONG&gt;i&lt;/STRONG&gt;&lt;/FONT&gt;=0 to x.count-1&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;ActiveDocument.Fields("Field1").Select x.item(&lt;STRONG&gt;&lt;FONT color="#339966"&gt;i&lt;/FONT&gt;&lt;/STRONG&gt;).Text&lt;BR /&gt;next&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jun 2019 12:08:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-looping-through-two-fields/m-p/1597199#M595696</guid>
      <dc:creator>cwolf</dc:creator>
      <dc:date>2019-06-28T12:08:17Z</dc:date>
    </item>
  </channel>
</rss>

