<?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 getting previous year value with if statement in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/getting-previous-year-value-with-if-statement/m-p/559850#M208974</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I'm migrating some reports from BusinessObjects to QlikView. I find difficult to calculate the previous year price for materials. I tried in two ways:&lt;BR /&gt;- using set analysis: =Sum({&amp;lt;YEAR = {$(vPY)}&amp;gt;} PRICE) &lt;BR /&gt;- using if statement: =sum(if(YEAR = vPY, PRICE)&lt;BR /&gt;where vPY = max(YEAR)-1&lt;/P&gt;&lt;P&gt;The problem is that if I use set analysis I don't get the values I expect (even there are little differences) because BusinessObjects uses If Statement in formulas and I imagine the set analysis logic is different from if statement logic.&lt;BR /&gt;I'd like to choose if statement way instead of set analysis but the problem is that my formula doesn't work. It displays no values in the column. Can you help me getting the previous year price value using if statement, please?&lt;BR /&gt;Another solution I was thinking was to calculate the value into the load script, but the PRICE is calculated based on fields from different tables and for a newbie like me it seems pretty difficult.&lt;/P&gt;&lt;P&gt;Any ideas?&lt;BR /&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 24 Sep 2013 11:57:46 GMT</pubDate>
    <dc:creator />
    <dc:date>2013-09-24T11:57:46Z</dc:date>
    <item>
      <title>getting previous year value with if statement</title>
      <link>https://community.qlik.com/t5/QlikView/getting-previous-year-value-with-if-statement/m-p/559850#M208974</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I'm migrating some reports from BusinessObjects to QlikView. I find difficult to calculate the previous year price for materials. I tried in two ways:&lt;BR /&gt;- using set analysis: =Sum({&amp;lt;YEAR = {$(vPY)}&amp;gt;} PRICE) &lt;BR /&gt;- using if statement: =sum(if(YEAR = vPY, PRICE)&lt;BR /&gt;where vPY = max(YEAR)-1&lt;/P&gt;&lt;P&gt;The problem is that if I use set analysis I don't get the values I expect (even there are little differences) because BusinessObjects uses If Statement in formulas and I imagine the set analysis logic is different from if statement logic.&lt;BR /&gt;I'd like to choose if statement way instead of set analysis but the problem is that my formula doesn't work. It displays no values in the column. Can you help me getting the previous year price value using if statement, please?&lt;BR /&gt;Another solution I was thinking was to calculate the value into the load script, but the PRICE is calculated based on fields from different tables and for a newbie like me it seems pretty difficult.&lt;/P&gt;&lt;P&gt;Any ideas?&lt;BR /&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Sep 2013 11:57:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/getting-previous-year-value-with-if-statement/m-p/559850#M208974</guid>
      <dc:creator />
      <dc:date>2013-09-24T11:57:46Z</dc:date>
    </item>
    <item>
      <title>Re: getting previous year value with if statement</title>
      <link>https://community.qlik.com/t5/QlikView/getting-previous-year-value-with-if-statement/m-p/559851#M208975</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi !&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You need to use double quotes, like this:&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;"&gt;=Sum({&amp;lt;YEAR = {"$(vPY)"}&amp;gt;} PRICE)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;or for static year&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;=Sum({&amp;lt;YEAR = {"$(=year(today())-1)"}&amp;gt;} PRICE)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Bye !&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Sep 2013 20:13:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/getting-previous-year-value-with-if-statement/m-p/559851#M208975</guid>
      <dc:creator />
      <dc:date>2013-09-24T20:13:43Z</dc:date>
    </item>
    <item>
      <title>Re: getting previous year value with if statement</title>
      <link>https://community.qlik.com/t5/QlikView/getting-previous-year-value-with-if-statement/m-p/559852#M208976</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Double quotes are only needed for search, so I don't believe that this is the problem in this case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think what's missing in the Set Analysis formula is the equal sign within the $-sign expansion. The variable contains a formula, hence the $-sign expansion needs to begin with an equal sign. Or, the other way - the variable can include the equal sign and then the set analysis won't need it:&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: 12.800000190734863px;"&gt;using set analysis: =Sum({&amp;lt;YEAR = {$(&lt;STRONG&gt;=&lt;/STRONG&gt;vPY)}&amp;gt;} PRICE) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; line-height: 1.5em;"&gt;where vPY = 'max(YEAR)-1'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; line-height: 1.5em;"&gt;or&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px;"&gt; using set analysis: =Sum({&amp;lt;YEAR = {$(vPY)}&amp;gt;} PRICE) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; line-height: 1.5em;"&gt;where vPY = '&lt;STRONG&gt;=&lt;/STRONG&gt;max(YEAR)-1'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; line-height: 1.5em;"&gt;The formula with an IF has similar problems, but using IF is not recommended anyway, so I won't waste your time explaining it...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; line-height: 1.5em;"&gt;You can learn more about $-sign expansions from my recent blog:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; line-height: 1.5em;"&gt;&lt;A href="http://www.naturalsynergies.com/q-tip-6-those-tricky-sign-expansions/"&gt;http://www.naturalsynergies.com/q-tip-6-those-tricky-sign-expansions/&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; line-height: 1.5em;"&gt;cheers,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; line-height: 1.5em;"&gt;Oleg Troyansky&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Sep 2013 21:37:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/getting-previous-year-value-with-if-statement/m-p/559852#M208976</guid>
      <dc:creator>Oleg_Troyansky</dc:creator>
      <dc:date>2013-09-24T21:37:06Z</dc:date>
    </item>
  </channel>
</rss>

