<?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 Define Variable based on week in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Define-Variable-based-on-week/m-p/226064#M499876</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Removed too big and confusing&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 27 Apr 2011 16:57:08 GMT</pubDate>
    <dc:creator />
    <dc:date>2011-04-27T16:57:08Z</dc:date>
    <item>
      <title>Define Variable based on week</title>
      <link>https://community.qlik.com/t5/QlikView/Define-Variable-based-on-week/m-p/226059#M499871</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi I have this problem with the loop.&lt;/P&gt;&lt;P&gt;I am looping with the weeks and my loop is for 201115[vCurrweek] to 201118($(vCurWeek)+3)&lt;/P&gt;&lt;P&gt;If the "week" Field in Temp_table is same as $(Vcurrweek) I want to save the stock as variable Stock.&lt;/P&gt;&lt;P&gt;I dont know how to write this&lt;/P&gt;&lt;P&gt;I tried&lt;/P&gt;&lt;P&gt;Let Stock = Peek('WeeklyStock');&lt;/P&gt;&lt;P&gt;But it does not give me the Stockvalue when week is 'i'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE ___default_attr="plain" class="jive_text_macro jive_macro_code" jivemacro="code"&gt;&lt;BR /&gt;SET CV= '0';&lt;BR /&gt;&lt;BR /&gt; For i= $(vCurWeek) to ($(vCurWeek)+3)&lt;BR /&gt;&lt;BR /&gt; Temp_Table:&lt;BR /&gt; Load&lt;BR /&gt; SID_0CALWEEK as Week,&lt;BR /&gt; Material as Material,&lt;BR /&gt; SID_CMATLOC as [Location],&lt;BR /&gt; [Weekly Material Stock] as WeeklyStock,&lt;BR /&gt; [Weekly Material Demand] as WeeklyDemand&lt;BR /&gt; Resident FactTable&lt;BR /&gt; ;&lt;BR /&gt;&lt;BR /&gt; if($(i) = Fieldvalue(Week)) then&lt;BR /&gt; Let Stock = Fieldvalue('WeeklyStock');&lt;BR /&gt; Endif&lt;BR /&gt;&lt;BR /&gt; If($(Stock) &amp;lt;= 0) then $(CV) else&lt;BR /&gt; exit script()&lt;BR /&gt; End If&lt;BR /&gt;........&lt;BR /&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;sravan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Apr 2011 12:31:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Define-Variable-based-on-week/m-p/226059#M499871</guid>
      <dc:creator />
      <dc:date>2011-04-21T12:31:42Z</dc:date>
    </item>
    <item>
      <title>Define Variable based on week</title>
      <link>https://community.qlik.com/t5/QlikView/Define-Variable-based-on-week/m-p/226060#M499872</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No Ideas???&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Apr 2011 13:50:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Define-Variable-based-on-week/m-p/226060#M499872</guid>
      <dc:creator />
      <dc:date>2011-04-21T13:50:48Z</dc:date>
    </item>
    <item>
      <title>Define Variable based on week</title>
      <link>https://community.qlik.com/t5/QlikView/Define-Variable-based-on-week/m-p/226061#M499873</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm curious about this part:&lt;/P&gt;&lt;PRE style="margin:0px;"&gt;if($(i) = Fieldvalue(Week)) then&lt;BR /&gt; Let Stock = Fieldvalue('WeeklyStock');&lt;BR /&gt; Endif&lt;BR /&gt;&lt;BR /&gt;Does the script go inside the if-case? You can use TRACE to check if the if-condition was ok...&lt;BR /&gt; if($(i) = Fieldvalue(Week)) then&lt;BR /&gt;TRACE IS OK;&lt;BR /&gt;&lt;BR /&gt; Let Stock = Fieldvalue('WeeklyStock');&lt;BR /&gt; Endif&lt;BR /&gt;&lt;BR /&gt;You are using the FieldValue in two different ways. On the first line of your code, try:&lt;BR /&gt; Fieldvalue('Week')&lt;BR /&gt;&lt;BR /&gt;Is week a numeric field to be compared with $i)?&lt;BR /&gt;&lt;BR /&gt;Rgds,&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Apr 2011 02:41:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Define-Variable-based-on-week/m-p/226061#M499873</guid>
      <dc:creator>erichshiino</dc:creator>
      <dc:date>2011-04-26T02:41:18Z</dc:date>
    </item>
    <item>
      <title>Define Variable based on week</title>
      <link>https://community.qlik.com/t5/QlikView/Define-Variable-based-on-week/m-p/226062#M499874</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;edit: Too big and confusing&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Apr 2011 12:12:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Define-Variable-based-on-week/m-p/226062#M499874</guid>
      <dc:creator />
      <dc:date>2011-04-27T12:12:56Z</dc:date>
    </item>
    <item>
      <title>Define Variable based on week</title>
      <link>https://community.qlik.com/t5/QlikView/Define-Variable-based-on-week/m-p/226063#M499875</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think I am doing some silly Mistake...&lt;/P&gt;&lt;P&gt;when I comment the whole "j" loop, "i" loop works correctly and also Stock variable is correct.&lt;/P&gt;&lt;P&gt;If I test for one "i" value, the whole "j" loop and "i" loop works good.&lt;/P&gt;&lt;P&gt;I wonder why after one i value and loop of J values it does not work for second i value in the loop!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Apr 2011 13:41:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Define-Variable-based-on-week/m-p/226063#M499875</guid>
      <dc:creator />
      <dc:date>2011-04-27T13:41:49Z</dc:date>
    </item>
    <item>
      <title>Define Variable based on week</title>
      <link>https://community.qlik.com/t5/QlikView/Define-Variable-based-on-week/m-p/226064#M499876</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Removed too big and confusing&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Apr 2011 16:57:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Define-Variable-based-on-week/m-p/226064#M499876</guid>
      <dc:creator />
      <dc:date>2011-04-27T16:57:08Z</dc:date>
    </item>
    <item>
      <title>Define Variable based on week</title>
      <link>https://community.qlik.com/t5/QlikView/Define-Variable-based-on-week/m-p/226065#M499877</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You are already using&lt;/P&gt;&lt;PRE style="margin:0px;"&gt;Trace $(Stock);&lt;BR /&gt;try to use trace $(i); and trace $(j) and trace $(vFieldValue2); and trace $(vFieldValue_2) to gather more information about what is going on&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Apr 2011 20:31:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Define-Variable-based-on-week/m-p/226065#M499877</guid>
      <dc:creator>erichshiino</dc:creator>
      <dc:date>2011-04-27T20:31:05Z</dc:date>
    </item>
    <item>
      <title>Define Variable based on week</title>
      <link>https://community.qlik.com/t5/QlikView/Define-Variable-based-on-week/m-p/226066#M499878</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Edit&lt;/P&gt;&lt;P&gt;Too complicated hence added a simple example later&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Apr 2011 18:19:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Define-Variable-based-on-week/m-p/226066#M499878</guid>
      <dc:creator />
      <dc:date>2011-04-28T18:19:55Z</dc:date>
    </item>
    <item>
      <title>Define Variable based on week</title>
      <link>https://community.qlik.com/t5/QlikView/Define-Variable-based-on-week/m-p/226067#M499879</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Erich,&lt;/P&gt;&lt;P&gt;I finally got it work but still have 2 questions. May be you can help me. The problem was between the concatenate and Peek expressions. Somehow peek does not work with concatenate for the tables t1 and t2 (I replaced with Noconcatenate and it works but generates lot of t tables)&lt;/P&gt;&lt;P&gt;When I keep noconcatenate load for t1 and t2 tables, it works but I get a lot of "t" tables. I want to do this calculation of cover for a lot of Materials by looping with each material and I see the problem that my Datamodel will be full of unlimited "t" tables.&lt;/P&gt;&lt;P style="font-weight: bold"&gt;First Question:&lt;/P&gt;&lt;P&gt;I need to get the CV values( defined as CV variable) in this manner within the table. &lt;B&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://community.qlik.com/cfs-file.ashx/__key/CommunityServer.Discussions.Components.Files/11/4505.Result.jpg"&gt;&lt;IMG alt="" border="0" src="http://community.qlik.com/resized-image.ashx/__size/550x0/__key/CommunityServer.Discussions.Components.Files/11/4505.Result.jpg" /&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;From the above table, the calculation which I made in Qlikview is based on this WordDocument&lt;/P&gt;&lt;P&gt;[View:http://community.qlik.com/cfs-file.ashx/__key/CommunityServer.Discussions.Components.Files/11/0763.COVERAGE-Calculation.docx:550:0]&lt;/P&gt;&lt;P style="font-weight: bold"&gt;I get the values CV in my script as a Variable and I need to somehow save them as Field "Cover" in the table "Temp_Table". How??&lt;BR /&gt;&lt;/P&gt;&lt;P style="font-weight: bold"&gt;Second Question:&lt;/P&gt;&lt;P&gt;&lt;B&gt;How to get the t tables reduced in the script&lt;/B&gt;&lt;B&gt;?&lt;/B&gt; I actually needed only &lt;B&gt;Coverage values&lt;/B&gt; and hence these loops. Otherwise I dont need the t tables&lt;B&gt;.&lt;BR /&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;I am attaching a simple example for the figure above showing the values.&lt;/P&gt;&lt;P&gt;Hope you can help me.&lt;/P&gt;&lt;P&gt;Thanks and regards&lt;/P&gt;&lt;P&gt;Sravan&lt;B&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;[View:http://community.qlik.com/cfs-file.ashx/__key/CommunityServer.Components.UserFiles/00.00.00.49.52/StockReportingExample1.qvw]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Apr 2011 12:58:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Define-Variable-based-on-week/m-p/226067#M499879</guid>
      <dc:creator />
      <dc:date>2011-04-29T12:58:38Z</dc:date>
    </item>
  </channel>
</rss>

