<?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 Include MaxString in a formula in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Include-MaxString-in-a-formula/m-p/176803#M44653</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a variable called MonthNum which is the number of the month in a financial year, therefore July = 1, August = 2 etc.&lt;/P&gt;&lt;P&gt;I want to be able to look at the average of a set of data as well as the current months data side by side.&lt;/P&gt;&lt;P&gt;To do this I have a formula to work out the average as:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE ___default_attr="plain" class="jive_text_macro jive_macro_code" jivemacro="code"&gt;&lt;BR /&gt;Avg(if(Year = vCurrentYear, Sales))&lt;BR /&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;When a range of months is selected this gives the average but at the same time I want a formula that will display the most recent month sales in the month range I select. So if I choose MonthNum 1 to 8 then the average gives me an average of 8 months data and the current month gives me the data for MonthNum = 8&lt;/P&gt;&lt;P&gt;I could do it like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE ___default_attr="plain" class="jive_text_macro jive_macro_code" jivemacro="code"&gt;&lt;BR /&gt;Sum(if(Year=vCurrentYear and MonthNum = 8, Sales) )&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;but then its stuck on month 8 until I change the formula.&lt;/P&gt;&lt;P&gt;If I add another expression and use&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE ___default_attr="plain" class="jive_text_macro jive_macro_code" jivemacro="code"&gt;&lt;BR /&gt;MaxString(MonthNum)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;I get 8 as the answer, so I want to be able to add these together but I cannot nest a MaxString into a Sum function.&lt;/P&gt;&lt;P&gt;This doesnt work&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE ___default_attr="plain" class="jive_text_macro jive_macro_code" jivemacro="code"&gt;&lt;BR /&gt;Sum(if(Year = vCurrentYear and MonthNum = MaxString(MonthNum), Sales))&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 07 Sep 2009 11:22:31 GMT</pubDate>
    <dc:creator />
    <dc:date>2009-09-07T11:22:31Z</dc:date>
    <item>
      <title>Include MaxString in a formula</title>
      <link>https://community.qlik.com/t5/QlikView/Include-MaxString-in-a-formula/m-p/176803#M44653</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a variable called MonthNum which is the number of the month in a financial year, therefore July = 1, August = 2 etc.&lt;/P&gt;&lt;P&gt;I want to be able to look at the average of a set of data as well as the current months data side by side.&lt;/P&gt;&lt;P&gt;To do this I have a formula to work out the average as:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE ___default_attr="plain" class="jive_text_macro jive_macro_code" jivemacro="code"&gt;&lt;BR /&gt;Avg(if(Year = vCurrentYear, Sales))&lt;BR /&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;When a range of months is selected this gives the average but at the same time I want a formula that will display the most recent month sales in the month range I select. So if I choose MonthNum 1 to 8 then the average gives me an average of 8 months data and the current month gives me the data for MonthNum = 8&lt;/P&gt;&lt;P&gt;I could do it like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE ___default_attr="plain" class="jive_text_macro jive_macro_code" jivemacro="code"&gt;&lt;BR /&gt;Sum(if(Year=vCurrentYear and MonthNum = 8, Sales) )&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;but then its stuck on month 8 until I change the formula.&lt;/P&gt;&lt;P&gt;If I add another expression and use&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE ___default_attr="plain" class="jive_text_macro jive_macro_code" jivemacro="code"&gt;&lt;BR /&gt;MaxString(MonthNum)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;I get 8 as the answer, so I want to be able to add these together but I cannot nest a MaxString into a Sum function.&lt;/P&gt;&lt;P&gt;This doesnt work&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE ___default_attr="plain" class="jive_text_macro jive_macro_code" jivemacro="code"&gt;&lt;BR /&gt;Sum(if(Year = vCurrentYear and MonthNum = MaxString(MonthNum), Sales))&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Sep 2009 11:22:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Include-MaxString-in-a-formula/m-p/176803#M44653</guid>
      <dc:creator />
      <dc:date>2009-09-07T11:22:31Z</dc:date>
    </item>
    <item>
      <title>Include MaxString in a formula</title>
      <link>https://community.qlik.com/t5/QlikView/Include-MaxString-in-a-formula/m-p/176804#M44654</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Set Analysis is your friend here:&lt;/P&gt;&lt;P&gt;sum({$&amp;lt;Year={$(=vCurrentYear)}, Month={$(=Maxstring(Month))}&amp;gt;} Sales)&lt;/P&gt;&lt;P&gt;This should do the trick.&lt;/P&gt;&lt;P&gt;//Jsn&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Sep 2009 12:59:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Include-MaxString-in-a-formula/m-p/176804#M44654</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-09-07T12:59:55Z</dc:date>
    </item>
    <item>
      <title>Include MaxString in a formula</title>
      <link>https://community.qlik.com/t5/QlikView/Include-MaxString-in-a-formula/m-p/176805#M44655</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Johannes,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;worked perfectly, Im guessing this is using set analysis which I never understood but can see what this is doing.&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;David&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Sep 2009 13:08:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Include-MaxString-in-a-formula/m-p/176805#M44655</guid>
      <dc:creator />
      <dc:date>2009-09-07T13:08:37Z</dc:date>
    </item>
  </channel>
</rss>

