<?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: select multiple field values with macro in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/select-multiple-field-values-with-macro/m-p/1755807#M455303</link>
    <description>&lt;P&gt;" ... does not work ..." isn't really helpful, what happens - it breaks in any way, any error-message is shown, nothing happens, it runs but doesn't select the right values ...?&lt;/P&gt;&lt;P&gt;Just from the view it looked ok. whereby I'm not sure if nesting a for-loop within a with-statement is valid/supported within VBS. Quite often are msgbox-statements very useful to find issues within the code, means something like:&lt;/P&gt;&lt;P&gt;msgbox n&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;msgbox err.number &amp;amp; " - " &amp;amp; err.description&lt;/P&gt;&lt;P&gt;Beside this I suggest to skip this part and to create appropriate continuous fieldvalues within the datamodel in the master-calendar. This may be done with autonumber(Year &amp;amp; '|' &amp;amp; Month) or with calculations like Year * 12 + Month.&lt;/P&gt;&lt;P&gt;With it you could use a logic like:&lt;/P&gt;&lt;P&gt;... fields("YearMonthXXX").select "&amp;gt;=YourValue"&lt;/P&gt;&lt;P&gt;Because of the fact that all your selections are related to today() you may even create appropriate flag-fields within the master-calendar so that you could simply use:&lt;/P&gt;&lt;P&gt;... fields("YearMonth&lt;STRONG&gt;Flag&lt;/STRONG&gt;").select &lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;</description>
    <pubDate>Mon, 26 Oct 2020 10:19:05 GMT</pubDate>
    <dc:creator>marcus_sommer</dc:creator>
    <dc:date>2020-10-26T10:19:05Z</dc:date>
    <item>
      <title>select multiple field values with macro</title>
      <link>https://community.qlik.com/t5/QlikView/select-multiple-field-values-with-macro/m-p/1755642#M455301</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I need a macro that allows you to dynamically select different values for the same field.&lt;BR /&gt;I have a field YearWeek that contains data in the format yyyy-ww,&amp;nbsp; for example 2020-40, 2020-4, 2020-42 ...&lt;BR /&gt;I would like to write a macro that would first select the current week, then export the table to Excel. Then select the last 12 weeks and export the same table to the same excel file. Sending to excel spreadsheet is not a problem, but the problem is to select weeks dynamically (weeks are determined using formulas or variables) using a macro.&lt;/P&gt;&lt;P&gt;I currently use two buttons that make weekly selections with selectinfield and run a macro.&amp;nbsp;I would like to combine these activities into one macro.&lt;/P&gt;&lt;P&gt;Riho&lt;/P&gt;</description>
      <pubDate>Sat, 24 Oct 2020 12:58:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/select-multiple-field-values-with-macro/m-p/1755642#M455301</guid>
      <dc:creator>riho92qv</dc:creator>
      <dc:date>2020-10-24T12:58:51Z</dc:date>
    </item>
    <item>
      <title>Re: select multiple field values with macro</title>
      <link>https://community.qlik.com/t5/QlikView/select-multiple-field-values-with-macro/m-p/1755709#M455302</link>
      <description>&lt;P&gt;&lt;FONT size="4" color="#000000"&gt;Hi&lt;BR /&gt;I was looking for more solutions and working macros are Test2 and test3. Unfortunately, they are very 'awkward'.&lt;BR /&gt;Macro test4 does not work. Maybe someone can suggest a more elegant solution&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&lt;FONT size="2"&gt;sub test2&lt;/FONT&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&lt;FONT size="2"&gt;With ActiveDocument.Fields("YearMonth")&lt;/FONT&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&lt;FONT size="2"&gt;&amp;nbsp; &amp;nbsp; .Select ActiveDocument.Evaluate("Date(Date#(AddMonths(Today(),0), 'DD.MM.YYYY'), 'YYYY-MM')")&lt;/FONT&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&lt;FONT size="2"&gt;&amp;nbsp; &amp;nbsp; .ToggleSelect ActiveDocument.Evaluate("Date(Date#(AddMonths(Today(),-1), 'DD.MM.YYYY'), 'YYYY-MM')")&lt;/FONT&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&lt;FONT size="2"&gt;&amp;nbsp; &amp;nbsp; .ToggleSelect ActiveDocument.Evaluate("Date(Date#(AddMonths(Today(),-2), 'DD.MM.YYYY'), 'YYYY-MM')") &lt;/FONT&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&lt;FONT size="2"&gt;&amp;nbsp; &amp;nbsp; .ToggleSelect ActiveDocument.Evaluate("Date(Date#(AddMonths(Today(),-3), 'DD.MM.YYYY'), 'YYYY-MM')")&lt;/FONT&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2" color="#808000"&gt;&lt;I&gt;&amp;nbsp; &amp;nbsp; ''''''&amp;nbsp; etc.&lt;/I&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&lt;FONT size="2"&gt;End With &lt;/FONT&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&lt;FONT size="2"&gt;end sub&lt;/FONT&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&lt;FONT size="2"&gt;'---------------------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;sub test3&lt;/FONT&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&lt;FONT size="2"&gt;With ActiveDocument.Fields("YearWeek")&lt;/FONT&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&lt;FONT size="2"&gt;&amp;nbsp; &amp;nbsp; .Select ActiveDocument.Evaluate("Year(Today() - 0 * 7 ) &amp;amp; '-' &amp;amp; Week(Today() - 0 * 7)")&lt;/FONT&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&lt;FONT size="2"&gt;&amp;nbsp; &amp;nbsp; .ToggleSelect ActiveDocument.Evaluate("Year(Today() - 1 * 7 ) &amp;amp; '-' &amp;amp; Week(Today() - 1 * 7)")&lt;/FONT&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&lt;FONT size="2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;.ToggleSelect ActiveDocument.Evaluate("Year(Today() - 2 * 7 ) &amp;amp; '-' &amp;amp; Week(Today() - 2 * 7)")&lt;/FONT&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&lt;FONT size="2"&gt;&amp;nbsp; &amp;nbsp; .ToggleSelect ActiveDocument.Evaluate("Year(Today() - 3 * 7 ) &amp;amp; '-' &amp;amp; Week(Today() - 3 * 7)")&lt;/FONT&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&lt;FONT size="2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;' . . . etc.&lt;/FONT&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&lt;FONT size="2"&gt;End With &lt;/FONT&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&lt;FONT size="2"&gt;end sub&lt;/FONT&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&lt;FONT size="2"&gt;'----------------------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;This macro does not work properly, cycle n = 1 to 4 does not work&lt;BR /&gt;&lt;/FONT&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&lt;FONT size="2"&gt;sub test4&lt;/FONT&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&lt;FONT size="2"&gt;With ActiveDocument.Fields("YearWeek")&lt;/FONT&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&lt;FONT size="2"&gt;&amp;nbsp; &amp;nbsp; .Select ActiveDocument.Evaluate("Year(Today() - 0 * 7 ) &amp;amp; '-' &amp;amp; Week(Today() - 0 * 7)")&lt;/FONT&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#808000"&gt;&lt;EM&gt;&lt;FONT size="2"&gt;&amp;nbsp; &amp;nbsp; For n = 1 to 4&lt;/FONT&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#808000"&gt;&lt;EM&gt;&lt;FONT size="2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .ToggleSelect ActiveDocument.Evaluate("Year(Today() - n * 7 ) &amp;amp; '-' &amp;amp; Week(Today() - n * 7)")&lt;/FONT&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&lt;FONT size="2"&gt;&lt;FONT color="#808000"&gt;&amp;nbsp; &amp;nbsp; Next&lt;/FONT&gt; &lt;/FONT&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&lt;FONT size="2"&gt;End With &lt;/FONT&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&lt;FONT size="2"&gt;end sub&lt;/FONT&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 25 Oct 2020 13:31:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/select-multiple-field-values-with-macro/m-p/1755709#M455302</guid>
      <dc:creator>riho92qv</dc:creator>
      <dc:date>2020-10-25T13:31:17Z</dc:date>
    </item>
    <item>
      <title>Re: select multiple field values with macro</title>
      <link>https://community.qlik.com/t5/QlikView/select-multiple-field-values-with-macro/m-p/1755807#M455303</link>
      <description>&lt;P&gt;" ... does not work ..." isn't really helpful, what happens - it breaks in any way, any error-message is shown, nothing happens, it runs but doesn't select the right values ...?&lt;/P&gt;&lt;P&gt;Just from the view it looked ok. whereby I'm not sure if nesting a for-loop within a with-statement is valid/supported within VBS. Quite often are msgbox-statements very useful to find issues within the code, means something like:&lt;/P&gt;&lt;P&gt;msgbox n&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;msgbox err.number &amp;amp; " - " &amp;amp; err.description&lt;/P&gt;&lt;P&gt;Beside this I suggest to skip this part and to create appropriate continuous fieldvalues within the datamodel in the master-calendar. This may be done with autonumber(Year &amp;amp; '|' &amp;amp; Month) or with calculations like Year * 12 + Month.&lt;/P&gt;&lt;P&gt;With it you could use a logic like:&lt;/P&gt;&lt;P&gt;... fields("YearMonthXXX").select "&amp;gt;=YourValue"&lt;/P&gt;&lt;P&gt;Because of the fact that all your selections are related to today() you may even create appropriate flag-fields within the master-calendar so that you could simply use:&lt;/P&gt;&lt;P&gt;... fields("YearMonth&lt;STRONG&gt;Flag&lt;/STRONG&gt;").select &lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;</description>
      <pubDate>Mon, 26 Oct 2020 10:19:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/select-multiple-field-values-with-macro/m-p/1755807#M455303</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2020-10-26T10:19:05Z</dc:date>
    </item>
    <item>
      <title>Re: select multiple field values with macro</title>
      <link>https://community.qlik.com/t5/QlikView/select-multiple-field-values-with-macro/m-p/1756045#M455304</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Marcus&lt;BR /&gt;thanks for the advice.&amp;nbsp;I tried to test a bit using msgbox.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;FONT size="2" color="#0000FF"&gt;sub test4&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT size="2" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; With ActiveDocument.Fields("YearWeek")&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT size="2" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .Select ActiveDocument.Evaluate("Year(Today(0) - 0 * 7 ) &amp;amp; '-' &amp;amp; Week(Today(0) - 0 * 7)")&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT size="2" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; For n = 1 to 4&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT size="2" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;msgbox a(n)&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT size="2" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; msgbox (ActiveDocument.Evaluate("Year(Today(0) - n * 7 ) &amp;amp; '-' &amp;amp; Week(Today(0) - n * 7)"))&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT size="2" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.ToggleSelect ActiveDocument.Evaluate("Year(Today(0) - n * 7 ) &amp;amp; '-' &amp;amp; Week(Today(0) - n * 7)")&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT size="2" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp;Next &lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT size="2" color="#0000FF"&gt;End With &lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT size="2" color="#0000FF"&gt;end sub&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;First msgbox returned numbers 1 to 4, but the second one returned only '-'.&lt;BR /&gt;I tested another expression:&lt;BR /&gt;&lt;FONT size="2" color="#0000FF"&gt;&lt;EM&gt;msgbox ActiveDocument.Evaluate("Year(Today(0) - 0 * 7 ) &amp;amp; '-' &amp;amp; Week(Today(0) - 0 * 7)")&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;it is ok, I conclude that the use of the variable n in the loop does not work.&lt;/P&gt;&lt;P&gt;Riho&lt;/P&gt;</description>
      <pubDate>Mon, 26 Oct 2020 19:38:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/select-multiple-field-values-with-macro/m-p/1756045#M455304</guid>
      <dc:creator>riho92qv</dc:creator>
      <dc:date>2020-10-26T19:38:43Z</dc:date>
    </item>
    <item>
      <title>Re: select multiple field values with macro</title>
      <link>https://community.qlik.com/t5/QlikView/select-multiple-field-values-with-macro/m-p/1756126#M455305</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;The last option is what happens:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;" ... does not work ..." isn't really helpful, what happens - it breaks in any way, any error-message is shown, nothing happens, &lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;it runs but doesn't select the right values&lt;/FONT&gt; &lt;/STRONG&gt;...?&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Riho&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Oct 2020 08:28:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/select-multiple-field-values-with-macro/m-p/1756126#M455305</guid>
      <dc:creator>riho92qv</dc:creator>
      <dc:date>2020-10-27T08:28:47Z</dc:date>
    </item>
    <item>
      <title>Re: select multiple field values with macro</title>
      <link>https://community.qlik.com/t5/QlikView/select-multiple-field-values-with-macro/m-p/1756239#M455306</link>
      <description>&lt;P&gt;Now I see the issue - you used evaluate() which transfers your statement within the UI and there the macro-variable n is unknown respectively hasn't a proper value.&lt;/P&gt;&lt;P&gt;To remain by your logic you could try it with an additionally step like:&lt;/P&gt;&lt;P&gt;ActiveDocument.Variables("n").SetContent n&lt;/P&gt;&lt;P&gt;Another method would be to create the right value directly within the macro, maybe with:&lt;/P&gt;&lt;P&gt;year(date - n * 7) &amp;amp; "-" &amp;amp; format(...)&lt;/P&gt;&lt;P&gt;How to get a proper week-value take a google-search AFAIK you need format() for it.&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;</description>
      <pubDate>Tue, 27 Oct 2020 13:03:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/select-multiple-field-values-with-macro/m-p/1756239#M455306</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2020-10-27T13:03:42Z</dc:date>
    </item>
  </channel>
</rss>

