<?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: Declare string for MTD and YTD in load script to use in set analysis in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Declare-string-for-MTD-and-YTD-in-load-script-to-use-in-set/m-p/1577386#M42067</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I did that, but still not getting an answer. Looking at the variable in the model, the text result looks like this:&lt;/P&gt;&lt;P&gt;{&amp;lt;Year= ,Month= ,Day= ,Week= ,[Week day]= ,Date={"&amp;gt;=&amp;lt;="}&amp;gt;}&lt;/P&gt;&lt;P&gt;it is missing the DSEs in the Date section. How do I do the SET declaration in the load script correctly? This one seems to exclude some details:&lt;/P&gt;&lt;P&gt;SET [MTD] = '{&amp;lt;Year=, Month=&amp;nbsp;,Day=&amp;nbsp;,Week=&amp;nbsp;,[Week day] =&amp;nbsp;,Date={"&amp;gt;=$(=MonthStart(vMaxDate))&amp;lt;=$(vMaxDate)"}&amp;gt;} '&lt;/P&gt;</description>
    <pubDate>Tue, 07 May 2019 12:23:59 GMT</pubDate>
    <dc:creator>ettienero</dc:creator>
    <dc:date>2019-05-07T12:23:59Z</dc:date>
    <item>
      <title>Declare string for MTD and YTD in load script to use in set analysis</title>
      <link>https://community.qlik.com/t5/App-Development/Declare-string-for-MTD-and-YTD-in-load-script-to-use-in-set/m-p/1577347#M42062</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I have several expressions using set analysis to determine sum of sales for periods MTD, YTD, etc. This is an example of one:&lt;/P&gt;&lt;P&gt;Sum({&amp;lt;Year=&amp;nbsp;,Month=&amp;nbsp;,Day=&amp;nbsp;,Week=&amp;nbsp;,[Week day] =&amp;nbsp;,Date={"&amp;gt;=$(=MonthStart(vMaxDate))&amp;lt;=$(vMaxDate)"}&amp;gt;} Sales) &amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been trying to declare the "set analysis" portion in the load script:&lt;/P&gt;&lt;P&gt;SET [MTD] = '{&amp;lt;Year=&amp;nbsp;,Month=&amp;nbsp;,Day=&amp;nbsp;,Week=&amp;nbsp;,[Week day] =&amp;nbsp;,Date={"&amp;gt;=$(=MonthStart(vMaxDate))&amp;lt;=$(vMaxDate)"}&amp;gt;}'&lt;/P&gt;&lt;P&gt;to use as a variable in the expressions like this: Sum($([MTD]) Sales)&lt;/P&gt;&lt;P&gt;, but this is not working.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would this be possible to do? and if so, can anybody please help with the correct syntax, etc.?&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2019 11:38:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Declare-string-for-MTD-and-YTD-in-load-script-to-use-in-set/m-p/1577347#M42062</guid>
      <dc:creator>ettienero</dc:creator>
      <dc:date>2019-05-07T11:38:19Z</dc:date>
    </item>
    <item>
      <title>Re: Declare string for MTD and YTD in load script to use in set analysis</title>
      <link>https://community.qlik.com/t5/App-Development/Declare-string-for-MTD-and-YTD-in-load-script-to-use-in-set/m-p/1577369#M42064</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;Try using&amp;nbsp;&lt;SPAN&gt;Sum($(&lt;STRONG&gt;MTD&lt;/STRONG&gt;) Sales)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;RT&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2019 12:02:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Declare-string-for-MTD-and-YTD-in-load-script-to-use-in-set/m-p/1577369#M42064</guid>
      <dc:creator>Neymar_Jr</dc:creator>
      <dc:date>2019-05-07T12:02:18Z</dc:date>
    </item>
    <item>
      <title>Re: Declare string for MTD and YTD in load script to use in set analysis</title>
      <link>https://community.qlik.com/t5/App-Development/Declare-string-for-MTD-and-YTD-in-load-script-to-use-in-set/m-p/1577386#M42067</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I did that, but still not getting an answer. Looking at the variable in the model, the text result looks like this:&lt;/P&gt;&lt;P&gt;{&amp;lt;Year= ,Month= ,Day= ,Week= ,[Week day]= ,Date={"&amp;gt;=&amp;lt;="}&amp;gt;}&lt;/P&gt;&lt;P&gt;it is missing the DSEs in the Date section. How do I do the SET declaration in the load script correctly? This one seems to exclude some details:&lt;/P&gt;&lt;P&gt;SET [MTD] = '{&amp;lt;Year=, Month=&amp;nbsp;,Day=&amp;nbsp;,Week=&amp;nbsp;,[Week day] =&amp;nbsp;,Date={"&amp;gt;=$(=MonthStart(vMaxDate))&amp;lt;=$(vMaxDate)"}&amp;gt;} '&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2019 12:23:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Declare-string-for-MTD-and-YTD-in-load-script-to-use-in-set/m-p/1577386#M42067</guid>
      <dc:creator>ettienero</dc:creator>
      <dc:date>2019-05-07T12:23:59Z</dc:date>
    </item>
    <item>
      <title>Re: Declare string for MTD and YTD in load script to use in set analysis</title>
      <link>https://community.qlik.com/t5/App-Development/Declare-string-for-MTD-and-YTD-in-load-script-to-use-in-set/m-p/1577392#M42069</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;&lt;P&gt;YeartoDate(DateField)*-1 as CurYTDFlag,&lt;/P&gt;&lt;P&gt;If(DateField &amp;gt;= MonthStart(Today(),0) and DateField &amp;lt;= Today(), 1, 0) as MTDFlag&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In your exp use Sum({&amp;lt;MTDFlag ={1}&amp;gt;}Sales)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;Sum({&amp;lt;CurYTDFlag={1}&amp;gt;}Sales)&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2019 12:38:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Declare-string-for-MTD-and-YTD-in-load-script-to-use-in-set/m-p/1577392#M42069</guid>
      <dc:creator>Uday_Pasupuleti</dc:creator>
      <dc:date>2019-05-07T12:38:16Z</dc:date>
    </item>
    <item>
      <title>Re: Declare string for MTD and YTD in load script to use in set analysis</title>
      <link>https://community.qlik.com/t5/App-Development/Declare-string-for-MTD-and-YTD-in-load-script-to-use-in-set/m-p/1577443#M42076</link>
      <description>&lt;P&gt;The $ expansions do not work when the Set is evaluated. You only need this expansion to happen in the front end, not during the load script, when these expansions will return nulls.&lt;/P&gt;&lt;P&gt;Using Set does NOT prevent $ expansion as it happens before the SET line executes.&amp;nbsp; The same with a LET statement.&lt;/P&gt;&lt;P&gt;You need to use deferred expansion of the $() expressions. You can do this a number of ways, and either of these will work. The choice is a question of style and taste:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Set MTD = {&amp;lt;Year= ,Month= ,Day= ,Week= ,[Week day] = ,Date={"&amp;gt;=#(=MonthStart(vMaxDate))&amp;lt;=#(vMaxDate)"}&amp;gt;};
Let MTD	= Replace(MTD, '#', '$');&lt;/LI-CODE&gt;&lt;P&gt;or&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Let MTD = '{&amp;lt;Year= ,Month= ,Day= ,Week= ,[Week day] = ,Date={"&amp;gt;=$' + '(=MonthStart(vMaxDate))&amp;lt;=$' + '(vMaxDate)"}&amp;gt;}';&lt;/LI-CODE&gt;&lt;P&gt;Both of these prevent the Set or Let from evaluating the $ expansion&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2019 13:32:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Declare-string-for-MTD-and-YTD-in-load-script-to-use-in-set/m-p/1577443#M42076</guid>
      <dc:creator>jonathandienst</dc:creator>
      <dc:date>2019-05-07T13:32:19Z</dc:date>
    </item>
  </channel>
</rss>

