<?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: Loadscript - creating a dimension with nested if regarding dates in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Loadscript-creating-a-dimension-with-nested-if-regarding-dates/m-p/1994667#M82335</link>
    <description>&lt;P&gt;I don't think you need a condition for every day of the week. If you are ok with the three digit abbreviation for weekday (Sat, Sun, etc) then you can use just the Weekday() function. Weekday returns a Dual with the three character name.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;IF(InWeek([Planned Picking Date],Today(),0), WeekDay([Planned Picking Date])) AS&amp;nbsp;[This Week]&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you require the full weekday name (Saturday, Sunday, etc) then I would do it like this:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;IF(InWeek([Planned Picking Date],Today(),0), Date([Planned Picking Date], 'WWWW')) AS&amp;nbsp;[This Week]&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Updated to use Marco's suggestion for InWeek(). &lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;-Rob&lt;BR /&gt;&lt;A href="http://www.easyqlik.com" target="_blank" rel="noopener"&gt;http://www.easyqlik.com&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://masterssummit.com" target="_blank" rel="noopener"&gt;http://masterssummit.com&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://qlikviewcookbook.com" target="_blank" rel="noopener"&gt;http://qlikviewcookbook.com&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 19 Oct 2022 23:18:13 GMT</pubDate>
    <dc:creator>rwunderlich</dc:creator>
    <dc:date>2022-10-19T23:18:13Z</dc:date>
    <item>
      <title>Loadscript - creating a dimension with nested if regarding dates</title>
      <link>https://community.qlik.com/t5/App-Development/Loadscript-creating-a-dimension-with-nested-if-regarding-dates/m-p/1994443#M82315</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;Sorry for the vague subject.&lt;/P&gt;
&lt;P&gt;But, I want to create a new field to use as a dimension based on a date field, where;&lt;/P&gt;
&lt;P&gt;1 - The date is within this week&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2 - The dates are then shown as Monday, Tuesday .. through Friday.&lt;/P&gt;
&lt;P&gt;I created the dates as Mon - Friday using;&lt;/P&gt;
&lt;P&gt;IF(WeekDay ([Planned Picking Date]) =0, 'Monday',&lt;BR /&gt;IF(WeekDay ([Planned Picking Date]) =1, 'Tuesday',&lt;BR /&gt;IF(WeekDay ([Planned Picking Date]) =2, 'Wednesday',&lt;BR /&gt;IF(WeekDay ([Planned Picking Date]) =3, 'Thursday',&lt;BR /&gt;IF(WeekDay ([Planned Picking Date]) =4, 'Friday'))))) AS [This Week],&lt;/P&gt;
&lt;P&gt;This produced when using a count on another field as the measure&amp;nbsp; &amp;nbsp;=Count(Delivery);&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Daryn_0-1666183501669.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/91685iC3B27316899CAEBB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Daryn_0-1666183501669.png" alt="Daryn_0-1666183501669.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But this doesn't limit&amp;nbsp; to the current week data.&lt;/P&gt;
&lt;P&gt;So I tried;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF([Planned Picking Date] =Week(today()), IF (WeekDay ([Planned Picking Date]) =0, 'Monday',&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF([Planned Picking Date] =Week(today()), IF (WeekDay ([Planned Picking Date]) =1, 'Tuesday',&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF([Planned Picking Date] =Week(today()), IF (WeekDay ([Planned Picking Date]) =2, 'Wednesday',&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF([Planned Picking Date] =Week(today()), IF (WeekDay ([Planned Picking Date]) =3, 'Thursday',&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF([Planned Picking Date] =Week(today()), IF (WeekDay ([Planned Picking Date]) =4, 'Friday')))))))))) AS [This Week],&lt;/P&gt;
&lt;P&gt;This loaded ok, but produced blank charts&lt;/P&gt;
&lt;P&gt;I tried and switched the if's around, but the same blank results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it possible, am I overcomplicating it?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance, hope I have supplied enough info.&lt;/P&gt;
&lt;P&gt;Regards&amp;nbsp; as always,&lt;/P&gt;
&lt;P&gt;Daryn&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 12:47:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Loadscript-creating-a-dimension-with-nested-if-regarding-dates/m-p/1994443#M82315</guid>
      <dc:creator>Daryn</dc:creator>
      <dc:date>2022-10-19T12:47:33Z</dc:date>
    </item>
    <item>
      <title>Re: Loadscript - creating a dimension with nested if regarding dates</title>
      <link>https://community.qlik.com/t5/App-Development/Loadscript-creating-a-dimension-with-nested-if-regarding-dates/m-p/1994449#M82316</link>
      <description>&lt;P&gt;Hi, this might just work - sample script:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;LET vMin = FLOOR(MAKEDATE(2022,1,1));
LET vMax = FLOOR(MAKEDATE(2022,12,31));

temp:
LOAD
$(vMin) + RECNO() - 1 AS [Planned Picking Date]
AUTOGENERATE $(vMax)-$(vMin)+1;

temp2:
LOAD
CEIL(RAND()*100) AS Sales,
CEIL(RAND()*ROWNO()) AS Delivery,
DATE([Planned Picking Date]) AS [Planned Picking Date],
IF([Planned Picking Date] &amp;gt;= FLOOR(WEEKSTART(TODAY())) AND [Planned Picking Date] &amp;lt;= WEEKEND(TODAY())-2,WEEKDAY([Planned Picking Date])) AS [This Week]
RESIDENT temp;

DROP TABLE temp;

&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I created a pie chart with:&lt;/P&gt;
&lt;P&gt;- measure : SUM(Delivery)&lt;/P&gt;
&lt;P&gt;- dimension: [This Week] (null values checked out in the properties).&lt;/P&gt;
&lt;P&gt;Other approach would be creating a flag for "this week" and using said flag in set analysis.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 12:59:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Loadscript-creating-a-dimension-with-nested-if-regarding-dates/m-p/1994449#M82316</guid>
      <dc:creator>RsQK</dc:creator>
      <dc:date>2022-10-19T12:59:34Z</dc:date>
    </item>
    <item>
      <title>Re: Loadscript - creating a dimension with nested if regarding dates</title>
      <link>https://community.qlik.com/t5/App-Development/Loadscript-creating-a-dimension-with-nested-if-regarding-dates/m-p/1994451#M82317</link>
      <description>&lt;P&gt;Hello Daryn&lt;BR /&gt;&lt;BR /&gt;How is your date field, doesn't' make sense create a master calendar Or a Autocalendar??&lt;BR /&gt;&lt;BR /&gt;Master calendar:&amp;nbsp;&lt;A href="https://community.qlik.com/t5/QlikView-App-Dev/Creating-A-Master-Calendar/td-p/341286" target="_blank" rel="noopener"&gt;Creating A Master Calendar - Qlik Community - 341286&lt;/A&gt;&lt;BR /&gt;Auto Calendar:&amp;nbsp;&lt;A href="https://community.qlik.com/t5/Official-Support-Articles/How-to-create-on-your-own-an-Autocalendar-Derived-fields/ta-p/1716542" target="_blank" rel="noopener"&gt;How to create on your own an Autocalendar (Derived... - Qlik Community - 1716542&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;When you can use fields directly from the master calendar or from auto calendar.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 12:59:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Loadscript-creating-a-dimension-with-nested-if-regarding-dates/m-p/1994451#M82317</guid>
      <dc:creator>ThiagoCN</dc:creator>
      <dc:date>2022-10-19T12:59:49Z</dc:date>
    </item>
    <item>
      <title>Re: Loadscript - creating a dimension with nested if regarding dates</title>
      <link>https://community.qlik.com/t5/App-Development/Loadscript-creating-a-dimension-with-nested-if-regarding-dates/m-p/1994469#M82320</link>
      <description>&lt;P&gt;Sorry, my bad explanation/terminology.&lt;/P&gt;
&lt;P&gt;The date 'Picking Date' is an auto calendar date.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 13:27:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Loadscript-creating-a-dimension-with-nested-if-regarding-dates/m-p/1994469#M82320</guid>
      <dc:creator>Daryn</dc:creator>
      <dc:date>2022-10-19T13:27:09Z</dc:date>
    </item>
    <item>
      <title>Re: Loadscript - creating a dimension with nested if regarding dates</title>
      <link>https://community.qlik.com/t5/App-Development/Loadscript-creating-a-dimension-with-nested-if-regarding-dates/m-p/1994471#M82321</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Thanks this certainly appears to work, I just need to check the data &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Then if all good I will mark as solution.&lt;/P&gt;
&lt;P&gt;Regards, Daryn&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 13:28:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Loadscript-creating-a-dimension-with-nested-if-regarding-dates/m-p/1994471#M82321</guid>
      <dc:creator>Daryn</dc:creator>
      <dc:date>2022-10-19T13:28:44Z</dc:date>
    </item>
    <item>
      <title>Re: Loadscript - creating a dimension with nested if regarding dates</title>
      <link>https://community.qlik.com/t5/App-Development/Loadscript-creating-a-dimension-with-nested-if-regarding-dates/m-p/1994667#M82335</link>
      <description>&lt;P&gt;I don't think you need a condition for every day of the week. If you are ok with the three digit abbreviation for weekday (Sat, Sun, etc) then you can use just the Weekday() function. Weekday returns a Dual with the three character name.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;IF(InWeek([Planned Picking Date],Today(),0), WeekDay([Planned Picking Date])) AS&amp;nbsp;[This Week]&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you require the full weekday name (Saturday, Sunday, etc) then I would do it like this:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;IF(InWeek([Planned Picking Date],Today(),0), Date([Planned Picking Date], 'WWWW')) AS&amp;nbsp;[This Week]&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Updated to use Marco's suggestion for InWeek(). &lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;-Rob&lt;BR /&gt;&lt;A href="http://www.easyqlik.com" target="_blank" rel="noopener"&gt;http://www.easyqlik.com&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://masterssummit.com" target="_blank" rel="noopener"&gt;http://masterssummit.com&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://qlikviewcookbook.com" target="_blank" rel="noopener"&gt;http://qlikviewcookbook.com&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 23:18:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Loadscript-creating-a-dimension-with-nested-if-regarding-dates/m-p/1994667#M82335</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2022-10-19T23:18:13Z</dc:date>
    </item>
    <item>
      <title>Re: Loadscript - creating a dimension with nested if regarding dates</title>
      <link>https://community.qlik.com/t5/App-Development/Loadscript-creating-a-dimension-with-nested-if-regarding-dates/m-p/1994716#M82339</link>
      <description>&lt;P&gt;To test for&amp;nbsp;&lt;SPAN&gt;[Planned Picking Date]&amp;nbsp; lying inside the current week you can also use the InWeek() function&lt;BR /&gt;(&lt;A href="https://help.qlik.com/en-US/sense/August2022/Subsystems/Hub/Content/Sense_Hub/Scripting/DateAndTimeFunctions/inweek.htm" target="_blank"&gt;https://help.qlik.com/en-US/sense/August2022/Subsystems/Hub/Content/Sense_Hub/Scripting/DateAndTimeFunctions/inweek.htm&lt;/A&gt;)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;i.e. like&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;InWeek([Planned Picking Date],Today(),0)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;another possible test would be&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;WeekStart([Planned Picking Date])=WeekStart(Today())&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 21:50:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Loadscript-creating-a-dimension-with-nested-if-regarding-dates/m-p/1994716#M82339</guid>
      <dc:creator>MarcoWedel</dc:creator>
      <dc:date>2022-10-19T21:50:13Z</dc:date>
    </item>
  </channel>
</rss>

