<?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 Applying multiple dynamic dates for a burst report in Qlik Automate</title>
    <link>https://community.qlik.com/t5/Qlik-Automate/Applying-multiple-dynamic-dates-for-a-burst-report/m-p/1982043#M850</link>
    <description>&lt;P&gt;Hello, I need some help adding multiple dates as selections to my sheet in a burst report.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First off, I am using the &lt;STRONG&gt;"Send a burst report to email recipients from a straight table"&amp;nbsp;&lt;/STRONG&gt;as described in&amp;nbsp;&lt;A href="https://community.qlik.com/t5/Knowledge/How-to-send-a-bursted-report-using-Qlik-Application-Automation/ta-p/1869364" target="_blank" rel="noopener"&gt;https://community.qlik.com/t5/Knowledge/How-to-send-a-bursted-report-using-Qlik-Application-Automation/ta-p/1869364&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looping through the list and applying selections based on the list and sending out corresponding emails to corresponding recipients works without problems.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;However, I also need to apply dynamic date ranges to the selection. Those are the same for each recipient.&lt;/P&gt;
&lt;P&gt;In my sheets, I use bookmarks to apply the date ranges.&lt;BR /&gt;The bookmark is set to use formulas that select all dates between two dates.&lt;BR /&gt;I use three alternate states for the Date ranges (last 4 weeks, 4 weeks before that and 2019) and apply each of them with it's own formula.&lt;/P&gt;
&lt;PRE&gt;=Date(Floor([bookingDate_leistung]))&amp;gt;= Date(Floor((vLast4WeekStart))) AND &lt;BR /&gt;Date(Floor([bookingDate_leistung]))&amp;lt;= Date(Floor((vLast4WeekEnd)))&lt;/PRE&gt;
&lt;P&gt;where the variables&amp;nbsp;&lt;EM&gt;vLast4WeekStart&lt;/EM&gt;&amp;nbsp;and &lt;EM&gt;vLast4WeekStart&lt;/EM&gt;&amp;nbsp;are defined like this:&lt;/P&gt;
&lt;PRE&gt; let vLast4WeekStart = date(WeekStart(Today(),-4),'DD.MM.YYYY');&lt;BR /&gt; let vLast4WeekEnd = date(WeekEnd(Today(),-1),'DD.MM.YYYY');&lt;/PRE&gt;
&lt;P&gt;the variables for the 2019 Date range are a bit more complicated:&lt;/P&gt;
&lt;PRE&gt;let v2019Year4WeekStart = MakeWeekDate(Year(WeekStart(Today(),-4))-3, Week((WeekStart(Today(),-4))), WeekDay((WeekStart(Today(),-4))));&lt;BR /&gt;let v2019Year4WeekEnd = MakeWeekDate(Year(WeekEnd(Today(),-1))-3, Week((WeekEnd(Today(),-1))), WeekDay((WeekEnd(Today(),-1))));&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried using the "Apply Bookmark" Qlik Cloud Service, however this does not affect the selection for the Qlik Reporting Service and I read in another thread that you would have to apply the selections with the "Add Selection to Sheet" reporting service.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am a bit lost on how to approach this.&lt;/P&gt;
&lt;P&gt;Is there any way to set those dynamic dates in the Qlik reporting services and loop between them in order to apply all needed dates to the selection?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;BR /&gt;Philip&lt;/P&gt;</description>
    <pubDate>Fri, 16 Sep 2022 14:21:54 GMT</pubDate>
    <dc:creator>Philip_Z</dc:creator>
    <dc:date>2022-09-16T14:21:54Z</dc:date>
    <item>
      <title>Applying multiple dynamic dates for a burst report</title>
      <link>https://community.qlik.com/t5/Qlik-Automate/Applying-multiple-dynamic-dates-for-a-burst-report/m-p/1982043#M850</link>
      <description>&lt;P&gt;Hello, I need some help adding multiple dates as selections to my sheet in a burst report.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First off, I am using the &lt;STRONG&gt;"Send a burst report to email recipients from a straight table"&amp;nbsp;&lt;/STRONG&gt;as described in&amp;nbsp;&lt;A href="https://community.qlik.com/t5/Knowledge/How-to-send-a-bursted-report-using-Qlik-Application-Automation/ta-p/1869364" target="_blank" rel="noopener"&gt;https://community.qlik.com/t5/Knowledge/How-to-send-a-bursted-report-using-Qlik-Application-Automation/ta-p/1869364&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looping through the list and applying selections based on the list and sending out corresponding emails to corresponding recipients works without problems.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;However, I also need to apply dynamic date ranges to the selection. Those are the same for each recipient.&lt;/P&gt;
&lt;P&gt;In my sheets, I use bookmarks to apply the date ranges.&lt;BR /&gt;The bookmark is set to use formulas that select all dates between two dates.&lt;BR /&gt;I use three alternate states for the Date ranges (last 4 weeks, 4 weeks before that and 2019) and apply each of them with it's own formula.&lt;/P&gt;
&lt;PRE&gt;=Date(Floor([bookingDate_leistung]))&amp;gt;= Date(Floor((vLast4WeekStart))) AND &lt;BR /&gt;Date(Floor([bookingDate_leistung]))&amp;lt;= Date(Floor((vLast4WeekEnd)))&lt;/PRE&gt;
&lt;P&gt;where the variables&amp;nbsp;&lt;EM&gt;vLast4WeekStart&lt;/EM&gt;&amp;nbsp;and &lt;EM&gt;vLast4WeekStart&lt;/EM&gt;&amp;nbsp;are defined like this:&lt;/P&gt;
&lt;PRE&gt; let vLast4WeekStart = date(WeekStart(Today(),-4),'DD.MM.YYYY');&lt;BR /&gt; let vLast4WeekEnd = date(WeekEnd(Today(),-1),'DD.MM.YYYY');&lt;/PRE&gt;
&lt;P&gt;the variables for the 2019 Date range are a bit more complicated:&lt;/P&gt;
&lt;PRE&gt;let v2019Year4WeekStart = MakeWeekDate(Year(WeekStart(Today(),-4))-3, Week((WeekStart(Today(),-4))), WeekDay((WeekStart(Today(),-4))));&lt;BR /&gt;let v2019Year4WeekEnd = MakeWeekDate(Year(WeekEnd(Today(),-1))-3, Week((WeekEnd(Today(),-1))), WeekDay((WeekEnd(Today(),-1))));&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried using the "Apply Bookmark" Qlik Cloud Service, however this does not affect the selection for the Qlik Reporting Service and I read in another thread that you would have to apply the selections with the "Add Selection to Sheet" reporting service.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am a bit lost on how to approach this.&lt;/P&gt;
&lt;P&gt;Is there any way to set those dynamic dates in the Qlik reporting services and loop between them in order to apply all needed dates to the selection?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;BR /&gt;Philip&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 14:21:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Qlik-Automate/Applying-multiple-dynamic-dates-for-a-burst-report/m-p/1982043#M850</guid>
      <dc:creator>Philip_Z</dc:creator>
      <dc:date>2022-09-16T14:21:54Z</dc:date>
    </item>
    <item>
      <title>Re: Applying multiple dynamic dates for a burst report</title>
      <link>https://community.qlik.com/t5/Qlik-Automate/Applying-multiple-dynamic-dates-for-a-burst-report/m-p/1983135#M866</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;
&lt;P&gt;just letting you know, after a lot of trial and error and researching, &lt;STRONG&gt;I finally found a solution&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/STRONG&gt;. &lt;BR /&gt;As there might be others having problems with this, I will share the details with you.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;The solution I found to this problem is pretty much what I was asking for in the first post:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&amp;nbsp;Grab the Variable values for the Timeframes from the Qlik App with the "Get Variable" Qlik Cloud service.&lt;/LI&gt;
&lt;LI&gt;Make a loop, starting from the first date and incrementing by one day until the end date is reached and write the values to a list variable.
&lt;UL&gt;
&lt;LI&gt;Format the list output in a way that each value is in the correct numerical format so that it can be applied to the date Field.&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;Apply the formatted list output to the selection as Raw input&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H4&gt;&lt;STRONG&gt;Detailed Solution:&lt;/STRONG&gt;&lt;/H4&gt;
&lt;H5&gt;&lt;STRONG&gt;Step 1.&lt;/STRONG&gt;&lt;/H5&gt;
&lt;P&gt;Get the Variables for the Start and End date. &lt;BR /&gt;My dates are defined like this (you can use another format as long as they are saved as Dates):&lt;/P&gt;
&lt;PRE&gt;let vLast4WeekStart = date(WeekStart(Today(),-4),'DD.MM.YYYY');&lt;BR /&gt;let vLast4WeekEnd = date(WeekEnd(Today(),-1),'DD.MM.YYYY');&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Get Variables from the App in sequence:&lt;/STRONG&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Philip_Z_0-1663673397285.png" style="width: 200px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/89440i532239438B9E50A2/image-size/small?v=v2&amp;amp;px=200" role="button" title="Philip_Z_0-1663673397285.png" alt="Philip_Z_0-1663673397285.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H5&gt;&lt;STRONG&gt;Step 2.&amp;nbsp;&lt;/STRONG&gt;&lt;/H5&gt;
&lt;P&gt;Create a list of dates between the start and end date.&lt;BR /&gt;&lt;SPAN&gt;I did this with a simple custom nodejs script.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;&lt;EM&gt;After getting the Variables, apply a custom code&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Philip_Z_1-1663673514209.png" style="width: 200px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/89441iFDF75E37B9834531/image-size/small?v=v2&amp;amp;px=200" role="button" title="Philip_Z_1-1663673514209.png" alt="Philip_Z_1-1663673514209.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;STRONG&gt;2.1&lt;/STRONG&gt; &lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;The script has the start and end date as inputs&amp;nbsp; in the format of a UNIX Timestamp, divided by 86400 (to get the day-scope instead of seconds).&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{divide: {date: {$.getVariable.qDefinition},'U'}, 86400}&lt;/LI-CODE&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Cust&lt;/STRONG&gt;&lt;STRONG&gt;om Code S&lt;/STRONG&gt;&lt;STRONG style="font-family: inherit;"&gt;ettings:&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Philip_Z_2-1663674092031.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/89443iC9A5949D6D250143/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Philip_Z_2-1663674092031.png" alt="Philip_Z_2-1663674092031.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;2.2.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;In the Script, cast the date Values to Numbers (to be sure they are interpreted correctly) and save them in variables to be used in the script.&lt;/LI&gt;
&lt;LI&gt;Then save the difference between the two values to a new variable &lt;EM&gt;diffD&lt;/EM&gt; to get the number of dates between the start end end Date. Don't forget to add +1 to include the end date.&lt;/LI&gt;
&lt;LI&gt;Loop through all the days,&amp;nbsp;starting from the startdate until the end date is reached (the number of loops is defined by the difference in days defined in &lt;EM&gt;diffD).&lt;/EM&gt;&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;Increment the Date by +1 for each loop.&lt;/LI&gt;
&lt;LI&gt;For each loop, push the current date to an array.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;And here is the IMPORTANT part, that cost me a lot of time and nerves, since I did not realize this:&amp;nbsp;&lt;BR /&gt;&lt;/STRONG&gt;Add 25569 to each date, because Qlik calculates the date values by counting from&amp;nbsp;&lt;SPAN&gt;01.01.1970 (same as Excel) and not counting from 01.01.1900&amp;nbsp;as the Unix-ts.&amp;nbsp;25569 is the difference in days between these two dates, so you must add these!&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Log the array in the console, so it can be used in later automation modules&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;LI-CODE lang="javascript"&gt;//Inputs from Variables.
//They have to be formatted as an Unix Timestamp devided by 86400 (to get the Date instead of seconds)
const startD = Number(inputs['dateStart']);
const endD = Number(inputs['dateEnd']);

//Calculate difference in days between the two dates
const diffD = endD - startD +1;

//Set dynamic variables for the loop
let currD = startD;
let dateList = [];

//loop from Start date until the end date and push to an Array
//Add 25569 to each date value (the difference in days between 01.01.1900 and 01.01.1970) in order to get the correct numerical date values
for (let i = 0; i &amp;lt; diffD; i++){
  dateList.push(currD+25569);
  currD++;
}

console.log(dateList);&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;2.3.&lt;BR /&gt;&lt;/STRONG&gt;Add the custom code as a &lt;STRONG&gt;Raw input&lt;/STRONG&gt;&amp;nbsp;to the values selection of your Date-Field&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Philip_Z_1-1663676767666.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/89447i1E739DD22093707C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Philip_Z_1-1663676767666.png" alt="Philip_Z_1-1663676767666.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Philip_Z_2-1663676794125.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/89449i4EC674A364AA0284/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Philip_Z_2-1663676794125.png" alt="Philip_Z_2-1663676794125.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And that is it. I repeat this flow 3 times, for each Alternate State.&lt;/P&gt;
&lt;P&gt;I will probably use this workflow as a template for all exports I create with the Qlik Reporting Connector, since our Apps usually have to be filtered to specific timeframes.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;EM&gt;Full Sequence as reference:&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Philip_Z_3-1663676900139.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/89450i67233BDF931AD394/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Philip_Z_3-1663676900139.png" alt="Philip_Z_3-1663676900139.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also special thanks to&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/134157"&gt;@Emile_Koslowski&lt;/a&gt;&amp;nbsp; since the details you provided in&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;A href="https://community.qlik.com/t5/Knowledge/How-to-add-a-list-of-values-in-a-selection-to-a-report-in-Qlik/ta-p/1890459&amp;nbsp;" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;this thread&lt;/STRONG&gt;&lt;/A&gt;&amp;nbsp;, especially your last remark to the other user to check how dates from the date Field are saved as a Raw Input, helped a lot.&lt;BR /&gt;Before that, I was trying to apply the dates in a text representation, which strangely worked for one date, but not an array of dates.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2022 12:36:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Qlik-Automate/Applying-multiple-dynamic-dates-for-a-burst-report/m-p/1983135#M866</guid>
      <dc:creator>Philip_Z</dc:creator>
      <dc:date>2022-09-20T12:36:35Z</dc:date>
    </item>
    <item>
      <title>Re: Applying multiple dynamic dates for a burst report</title>
      <link>https://community.qlik.com/t5/Qlik-Automate/Applying-multiple-dynamic-dates-for-a-burst-report/m-p/2139922#M2702</link>
      <description>&lt;P&gt;Hello, thanks for your solution !&lt;/P&gt;
&lt;P&gt;I've adapted it in php and without the get variables :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="php"&gt;// Date de début et de fin
$debut = new \DateTime('30 days ago');
$fin = new \DateTime();
 
// Ne pas toucher le code ci-dessous :
//Transformation des dates au format Qlik
$start = (int)($debut-&amp;gt;getTimestamp()/86400+25569);
$end = (int)($fin-&amp;gt;getTimestamp()/86400+25569);

//Tableaux des dates à filtrer
$tabDates = [];
for($i = $start; $i&amp;lt;= $end; $i++) {
	$tabDates[] = $i;
}
//Output du tableau
echo json_encode($tabDates);&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;and just add to selection the result of this custom code.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2023 15:58:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Qlik-Automate/Applying-multiple-dynamic-dates-for-a-burst-report/m-p/2139922#M2702</guid>
      <dc:creator>Ldi</dc:creator>
      <dc:date>2023-11-21T15:58:15Z</dc:date>
    </item>
    <item>
      <title>Re: Applying multiple dynamic dates for a burst report</title>
      <link>https://community.qlik.com/t5/Qlik-Automate/Applying-multiple-dynamic-dates-for-a-burst-report/m-p/2433193#M3366</link>
      <description>&lt;P&gt;Hey Ldi,&lt;/P&gt;
&lt;P&gt;I have a new Account, but I am the OP of this thread.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your nice addition.&lt;/P&gt;
&lt;P&gt;That is actually a great simplification of my approach for getting the correct date-values.&lt;/P&gt;
&lt;P&gt;I like that you do all the transformations in code and might just adapt mine to do the same. I Have not worked much with php yet but that might be just the chance. And otherwise I can just transform it to my JS-Script.&lt;/P&gt;
&lt;P&gt;I do like to pull the dates from variables to reflect possible changes in my app in my automation and I do calculations to get the start and end of the week which is pretty simple in the Qlik Data Editor.&lt;/P&gt;
&lt;P&gt;However, I do like the possiblity of doing this in Script. I have never seen it the way you do it: e.g. \DateTime('30 days ago'). Is there any documentation for that?&lt;/P&gt;
&lt;P&gt;Thanks,&lt;BR /&gt;Philip&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 09:10:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Qlik-Automate/Applying-multiple-dynamic-dates-for-a-burst-report/m-p/2433193#M3366</guid>
      <dc:creator>PhilipZ</dc:creator>
      <dc:date>2024-03-21T09:10:11Z</dc:date>
    </item>
  </channel>
</rss>

