<?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: Need to dynamically filter a six week range, based on selected week and year in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Need-to-dynamically-filter-a-six-week-range-based-on-selected/m-p/2504006#M103708</link>
    <description>&lt;P&gt;Marcus,&lt;/P&gt;
&lt;P&gt;I appreciate the additional information, but I don't think I understand where this additional script would go. You mentioned an example earlier with a "WeekFlag" and I don't see that being created anywhere. Can you explain further please?&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 31 Jan 2025 18:08:50 GMT</pubDate>
    <dc:creator>mikegrattan</dc:creator>
    <dc:date>2025-01-31T18:08:50Z</dc:date>
    <item>
      <title>Need to dynamically filter a six week range, based on selected week and year</title>
      <link>https://community.qlik.com/t5/App-Development/Need-to-dynamically-filter-a-six-week-range-based-on-selected/m-p/2503633#M103632</link>
      <description>&lt;P&gt;Let's say I have the following fields in a table:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;ShipDate&lt;/LI&gt;
&lt;LI&gt;Week&lt;/LI&gt;
&lt;LI&gt;Year&lt;/LI&gt;
&lt;LI&gt;QuantityShipped&lt;/LI&gt;
&lt;LI&gt;Six Week Average&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;If a person selects a week and a year, I want to dynamically calculate the Six Week Average of Quantity Shipped. Keeping in mind that a person could choose some combination of Week and Year that would overlap to another year, perhaps the best approach would be something like this:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Find the WeekStart day of Week and Year to get the ending date of the Six Week period.&lt;/LI&gt;
&lt;LI&gt;Count backwards six weeks from the WeekStart date to get the beginning of the Six Week period.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Now...how to put that in an expression so it can be done dynamically?&lt;/P&gt;
&lt;P&gt;I started by trying this equation just to get the WeekStart of the ShipDate, but it returns records for all years and weeks, even though I specified variable values of '05' for the Week, and '2025' for the year:&lt;/P&gt;
&lt;P&gt;=WeekStart({&amp;lt;Week={'$(vWeek)'},ShipYear={'$(vYear)'}&amp;gt;}ShipDate)&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mikegrattan_0-1738189507624.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/177053i26DE207E0BDD64A8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mikegrattan_0-1738189507624.png" alt="mikegrattan_0-1738189507624.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any ideas or suggestions would be greatly appreciated!&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jan 2025 22:25:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Need-to-dynamically-filter-a-six-week-range-based-on-selected/m-p/2503633#M103632</guid>
      <dc:creator>mikegrattan</dc:creator>
      <dc:date>2025-01-29T22:25:19Z</dc:date>
    </item>
    <item>
      <title>Re: Need to dynamically filter a six week range, based on selected week and year</title>
      <link>https://community.qlik.com/t5/App-Development/Need-to-dynamically-filter-a-six-week-range-based-on-selected/m-p/2503656#M103635</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/49220"&gt;@mikegrattan&lt;/a&gt;&amp;nbsp;Try below expression:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;WeekStart({&amp;lt;Week={"&amp;gt;=$(vWeek)-6&amp;lt;=$(vWeek)'},ShipYear={'$(vYear)'}&amp;gt;}ShipDate)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So when you select any week I will automatcally show your measure for that week range that is current week and 6 week s back&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2025 05:02:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Need-to-dynamically-filter-a-six-week-range-based-on-selected/m-p/2503656#M103635</guid>
      <dc:creator>Bhushan_Mahajan</dc:creator>
      <dc:date>2025-01-30T05:02:33Z</dc:date>
    </item>
    <item>
      <title>Re: Need to dynamically filter a six week range, based on selected week and year</title>
      <link>https://community.qlik.com/t5/App-Development/Need-to-dynamically-filter-a-six-week-range-based-on-selected/m-p/2503702#M103645</link>
      <description>&lt;P&gt;You need only a running and sorted week-counter over all data - within the master-calendar which is simply to create, for example with measurements like:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;interrecord-functions like peek() and previous()&lt;/LI&gt;
&lt;LI&gt;autonumber(Year&amp;amp;Week)&lt;/LI&gt;
&lt;LI&gt;calculation of: Year * 12 + Week&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;and then:&lt;/P&gt;
&lt;P&gt;sum({&amp;lt; WeekFlag = {"&amp;gt;=$(max(WeekFlag)-6)&amp;lt;=$(max(WeekFlag))"}&amp;gt;} Value)&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2025 09:08:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Need-to-dynamically-filter-a-six-week-range-based-on-selected/m-p/2503702#M103645</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2025-01-30T09:08:08Z</dc:date>
    </item>
    <item>
      <title>Re: Need to dynamically filter a six week range, based on selected week and year</title>
      <link>https://community.qlik.com/t5/App-Development/Need-to-dynamically-filter-a-six-week-range-based-on-selected/m-p/2503798#M103673</link>
      <description>&lt;P&gt;Hi Marcus. This sounds promising...could you provide more details? I have the following Master Calendar in the app:&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV&gt;SalesTemp:&lt;/DIV&gt;
&lt;DIV&gt;LOAD&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; min(ShipDate) AS minDate,&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; max(ShipDate) AS maxDate&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;RESIDENT&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; Sales;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;LET MinShipDate = Num(Peek('minDate', 0, 'SalesTemp'));&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;LET MaxShipDate = Num(Peek('maxDate', 0, 'SalesTemp'));&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;DROP TABLE SalesTemp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;//Temp Calendar&lt;/DIV&gt;
&lt;DIV&gt;temp_DateField:&lt;/DIV&gt;
&lt;DIV&gt;LOAD&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; $(MinShipDate) + rowno() -1 as Num,&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp;date($(MinShipDate) + rowno() -1 ) as TempDate&lt;/DIV&gt;
&lt;DIV&gt;AUTOGENERATE $(MaxShipDate) - $(MinShipDate)+1;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;//OrderDate Calendar&lt;/DIV&gt;
&lt;DIV&gt;shipdate_calendar:&lt;/DIV&gt;
&lt;DIV&gt;LOAD&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; TempDate as ShipDate, &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; Week(TempDate) AS ShipWeek,&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; Year(TempDate) as Year,&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; Month(TempDate) as Month,&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; Day(TempDate) as ShipDay &amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; Resident temp_DateField&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; ORDER BY TempDate ASC;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;DROP TABLE temp_DateField;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 30 Jan 2025 17:56:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Need-to-dynamically-filter-a-six-week-range-based-on-selected/m-p/2503798#M103673</guid>
      <dc:creator>mikegrattan</dc:creator>
      <dc:date>2025-01-30T17:56:12Z</dc:date>
    </item>
    <item>
      <title>Re: Need to dynamically filter a six week range, based on selected week and year</title>
      <link>https://community.qlik.com/t5/App-Development/Need-to-dynamically-filter-a-six-week-range-based-on-selected/m-p/2503875#M103679</link>
      <description>&lt;P&gt;It might be done in such ways:&lt;/P&gt;
&lt;DIV&gt;load *, Year * 12 + Week as Flag1,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;autonumber(Year&amp;amp;Week) as Flag2,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(Week = previous(Week), peek('Flag3'), peek('Flag3') + 1) as Flag3;&lt;BR /&gt;load *, week(Num) as Week, year(Num) as Year;&lt;BR /&gt;LOAD&amp;nbsp;&lt;SPAN&gt;$(MinShipDate) + rowno() -1 as Num,&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp;date($(MinShipDate) + rowno() -1 ) as TempDate&lt;/DIV&gt;
&lt;DIV&gt;AUTOGENERATE $(MaxShipDate) - $(MinShipDate)+1;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Beside this a master-calendar shouldn't be derived from facts else created independently - containing all relevant past/future years/decades for the entire environment with all kind of period-informations (n versions of numbers and strings for each, counters, flags, ...). And all the target-applications pick then the specific fields and periods from it - it's much more simple &amp;amp; powerful and of course more performant.&lt;/DIV&gt;</description>
      <pubDate>Fri, 31 Jan 2025 06:29:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Need-to-dynamically-filter-a-six-week-range-based-on-selected/m-p/2503875#M103679</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2025-01-31T06:29:08Z</dc:date>
    </item>
    <item>
      <title>Re: Need to dynamically filter a six week range, based on selected week and year</title>
      <link>https://community.qlik.com/t5/App-Development/Need-to-dynamically-filter-a-six-week-range-based-on-selected/m-p/2504006#M103708</link>
      <description>&lt;P&gt;Marcus,&lt;/P&gt;
&lt;P&gt;I appreciate the additional information, but I don't think I understand where this additional script would go. You mentioned an example earlier with a "WeekFlag" and I don't see that being created anywhere. Can you explain further please?&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2025 18:08:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Need-to-dynamically-filter-a-six-week-range-based-on-selected/m-p/2504006#M103708</guid>
      <dc:creator>mikegrattan</dc:creator>
      <dc:date>2025-01-31T18:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: Need to dynamically filter a six week range, based on selected week and year</title>
      <link>https://community.qlik.com/t5/App-Development/Need-to-dynamically-filter-a-six-week-range-based-on-selected/m-p/2504057#M103713</link>
      <description>&lt;P&gt;Flag 1 - 3 are (just different) ways to create the WeekFlag by skipping the resident-part and creating the period-information within n preceding-parts (it's just an example and not a fully calendar).&lt;/P&gt;
&lt;P&gt;Meant was to create the calendar within an own and independent application which may create hundreds of different period-information and storing them in n qvd's. It's not necessary to create these information redundant in n application else everything needed could be simply picked from the qvd's.&lt;/P&gt;</description>
      <pubDate>Sat, 01 Feb 2025 10:49:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Need-to-dynamically-filter-a-six-week-range-based-on-selected/m-p/2504057#M103713</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2025-02-01T10:49:45Z</dc:date>
    </item>
    <item>
      <title>Re: Need to dynamically filter a six week range, based on selected week and year</title>
      <link>https://community.qlik.com/t5/App-Development/Need-to-dynamically-filter-a-six-week-range-based-on-selected/m-p/2504249#M103740</link>
      <description>&lt;P&gt;Bhushan,&lt;/P&gt;
&lt;P&gt;Thanks for your suggestion. I did try it, but I got an error in set modifier ad hoc element list. Also, I believe that your approach would not work when the week is between 1 and 6, since it would result in a 0 or a negative number.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2025 19:25:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Need-to-dynamically-filter-a-six-week-range-based-on-selected/m-p/2504249#M103740</guid>
      <dc:creator>mikegrattan</dc:creator>
      <dc:date>2025-02-03T19:25:01Z</dc:date>
    </item>
    <item>
      <title>Re: Need to dynamically filter a six week range, based on selected week and year</title>
      <link>https://community.qlik.com/t5/App-Development/Need-to-dynamically-filter-a-six-week-range-based-on-selected/m-p/2504666#M103822</link>
      <description>&lt;P&gt;Hi Marcus,&lt;/P&gt;
&lt;P&gt;This post came the closest to my eventual solution, so I'll accept it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I ended up&amp;nbsp; doing the following:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Added a calendar object to the sheet&lt;/LI&gt;
&lt;LI&gt;User selects a date in calendar, and with that date I calculate a six week starting date and the six week ending date and place them in variables&lt;/LI&gt;
&lt;LI&gt;Using the variables, I can use calculations such as the following in order to get a six week average:&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;(Num(Sum({&amp;lt;ShipDate_DayOfWeek={'Thu'},FloorShipdate={"&amp;gt;=$(vStartSixWk)&amp;lt;=$(vEndSixWk)"}&amp;gt;}$(vMeasure))/6,'#,##0'))&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 18:13:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Need-to-dynamically-filter-a-six-week-range-based-on-selected/m-p/2504666#M103822</guid>
      <dc:creator>mikegrattan</dc:creator>
      <dc:date>2025-02-05T18:13:14Z</dc:date>
    </item>
  </channel>
</rss>

