<?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 string variable in formulas in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/string-variable-in-formulas/m-p/972883#M644231</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a table where I use the same expression&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum(if(NAME &amp;lt;&amp;gt; 'US Sales - Multi Year Portion' AND InMonth(STARTDATE,today(1),-x,1,0))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where "x" can be from 1 to 5, to show the leads that started in the last six months. I will probably have to add some other criteria&lt;/P&gt;&lt;P&gt;to this selection in the future, so I thought that if I could create a variable "vExpr1", that would only contain:&lt;/P&gt;&lt;P&gt;NAME &amp;lt;&amp;gt; 'US Sales - Multi Year Portion' AND InMonth(STARTDATE,today(1),&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and then my formula for every column would be sum(if($(vExpr1)-x,1,0)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I could add another condition (say AND Status &amp;lt;&amp;gt; '019' ) by just changing the definition of vExpr1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I tried&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SET vExpr1 = 'NAME &amp;lt;&amp;gt; 'US Sales - Multi Year Portion' AND InMonth(STARTDATE,today(1),'&lt;/P&gt;&lt;P&gt;and that didn't work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then I tried&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SET vExpr1 = 'NAME &amp;lt;&amp;gt; '&amp;amp;CHR(39)&amp;amp;'US Sales - Multi Year Portion'&amp;amp;chr(39)&amp;amp;'AND InMonth(STARTDATE,today(1)';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and that didn't work either. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First, is this a good idea (using the variable instead of spelling out each formula)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Second: If yes, what's the best way to do this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kevin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 24 Nov 2015 13:07:50 GMT</pubDate>
    <dc:creator />
    <dc:date>2015-11-24T13:07:50Z</dc:date>
    <item>
      <title>string variable in formulas</title>
      <link>https://community.qlik.com/t5/QlikView/string-variable-in-formulas/m-p/972883#M644231</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a table where I use the same expression&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum(if(NAME &amp;lt;&amp;gt; 'US Sales - Multi Year Portion' AND InMonth(STARTDATE,today(1),-x,1,0))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where "x" can be from 1 to 5, to show the leads that started in the last six months. I will probably have to add some other criteria&lt;/P&gt;&lt;P&gt;to this selection in the future, so I thought that if I could create a variable "vExpr1", that would only contain:&lt;/P&gt;&lt;P&gt;NAME &amp;lt;&amp;gt; 'US Sales - Multi Year Portion' AND InMonth(STARTDATE,today(1),&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and then my formula for every column would be sum(if($(vExpr1)-x,1,0)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I could add another condition (say AND Status &amp;lt;&amp;gt; '019' ) by just changing the definition of vExpr1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I tried&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SET vExpr1 = 'NAME &amp;lt;&amp;gt; 'US Sales - Multi Year Portion' AND InMonth(STARTDATE,today(1),'&lt;/P&gt;&lt;P&gt;and that didn't work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then I tried&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SET vExpr1 = 'NAME &amp;lt;&amp;gt; '&amp;amp;CHR(39)&amp;amp;'US Sales - Multi Year Portion'&amp;amp;chr(39)&amp;amp;'AND InMonth(STARTDATE,today(1)';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and that didn't work either. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First, is this a good idea (using the variable instead of spelling out each formula)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Second: If yes, what's the best way to do this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kevin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Nov 2015 13:07:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/string-variable-in-formulas/m-p/972883#M644231</guid>
      <dc:creator />
      <dc:date>2015-11-24T13:07:50Z</dc:date>
    </item>
    <item>
      <title>Re: string variable in formulas</title>
      <link>https://community.qlik.com/t5/QlikView/string-variable-in-formulas/m-p/972884#M644232</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this for the variable definition:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;SET vExpr1 = NAME &amp;lt;&amp;gt; 'US Sales - Multi Year Portion' AND InMonth(STARTDATE,today(1),;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Nov 2015 13:11:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/string-variable-in-formulas/m-p/972884#M644232</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2015-11-24T13:11:47Z</dc:date>
    </item>
    <item>
      <title>Re: string variable in formulas</title>
      <link>https://community.qlik.com/t5/QlikView/string-variable-in-formulas/m-p/972885#M644233</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks, Stefan. Worked perfectly!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Nov 2015 13:16:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/string-variable-in-formulas/m-p/972885#M644233</guid>
      <dc:creator />
      <dc:date>2015-11-24T13:16:03Z</dc:date>
    </item>
  </channel>
</rss>

