<?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: Issue with conditional previous year expression in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Issue-with-conditional-previous-year-expression/m-p/1570583#M442082</link>
    <description>Of course, how could I not see that? It solves Johan issue for sure!</description>
    <pubDate>Wed, 17 Apr 2019 14:05:22 GMT</pubDate>
    <dc:creator>jaibau1993</dc:creator>
    <dc:date>2019-04-17T14:05:22Z</dc:date>
    <item>
      <title>Issue with conditional previous year expression</title>
      <link>https://community.qlik.com/t5/QlikView/Issue-with-conditional-previous-year-expression/m-p/1570513#M442072</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;Hope you can assist me with a little issue. This last year formula works fine:&lt;/P&gt;&lt;P&gt;sum({&amp;lt;Year = {&lt;STRONG&gt;&lt;EM&gt;$(=max(Year) - 1)&lt;/EM&gt;&lt;/STRONG&gt;}&amp;gt;} SalesValue)&lt;/P&gt;&lt;P&gt;But when creating a dynamic expression:&lt;/P&gt;&lt;P&gt;if(&lt;STRONG&gt;&lt;EM&gt;$(vKPISales)&lt;/EM&gt;&lt;/STRONG&gt; = 'Sales value', &amp;nbsp;sum({&amp;lt;Year = {&lt;STRONG&gt;&lt;EM&gt;$(=max(Year) - 1)&lt;/EM&gt;&lt;/STRONG&gt;}&amp;gt;} SalesValue),&lt;/P&gt;&lt;P&gt;if(&lt;STRONG&gt;&lt;EM&gt;$(vKPISales)&lt;/EM&gt;&lt;/STRONG&gt; = 'Sales volume', sum({&amp;lt;Year = {&lt;STRONG&gt;&lt;EM&gt;$(=max(Year) - 1)&lt;/EM&gt;&lt;/STRONG&gt;}&amp;gt;} SalesVolume),’N/A’))&lt;/P&gt;&lt;P&gt;The straight table total row gives correct value. But rows that have sales in previous year (&lt;STRONG&gt;&lt;EM&gt;max(Year)-1)&lt;/EM&gt;&lt;/STRONG&gt; &lt;SPAN&gt;but not in current year (&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM&gt;max(Year)&lt;/EM&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;EM&gt;) returns &lt;/EM&gt;&lt;/STRONG&gt;’N/A’ with the expression above. Does anyone have an idea of why, and what to do about it?&lt;/P&gt;&lt;P&gt;Thanx&amp;nbsp;/Johan&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2019 12:41:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Issue-with-conditional-previous-year-expression/m-p/1570513#M442072</guid>
      <dc:creator>lindbergkarlsta</dc:creator>
      <dc:date>2019-04-17T12:41:14Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with conditional previous year expression</title>
      <link>https://community.qlik.com/t5/QlikView/Issue-with-conditional-previous-year-expression/m-p/1570543#M442077</link>
      <description>&lt;P&gt;Quite weird! Could you share a sample of your QlikView so we can test your issue? Aparently the sintax of your expression is correct.&lt;/P&gt;&lt;P&gt;Jaime.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2019 13:15:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Issue-with-conditional-previous-year-expression/m-p/1570543#M442077</guid>
      <dc:creator>jaibau1993</dc:creator>
      <dc:date>2019-04-17T13:15:20Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with conditional previous year expression</title>
      <link>https://community.qlik.com/t5/QlikView/Issue-with-conditional-previous-year-expression/m-p/1570572#M442081</link>
      <description>&lt;P&gt;Your variable contains string-values and therefore you need to wrap the call of it with single-quotes like:&lt;/P&gt;&lt;P&gt;if('&lt;STRONG&gt;&lt;EM&gt;$(vKPISales)'&lt;/EM&gt;&lt;/STRONG&gt; = 'Sales value', &amp;nbsp;sum({&amp;lt;Year = {&lt;STRONG&gt;&lt;EM&gt;$(=max(Year) - 1)&lt;/EM&gt;&lt;/STRONG&gt;}&amp;gt;} SalesValue),&lt;/P&gt;&lt;P&gt;if('&lt;STRONG&gt;&lt;EM&gt;$(vKPISales)&lt;/EM&gt;&lt;/STRONG&gt; '= 'Sales volume', sum({&amp;lt;Year = {&lt;STRONG&gt;&lt;EM&gt;$(=max(Year) - 1)&lt;/EM&gt;&lt;/STRONG&gt;}&amp;gt;} SalesVolume),’N/A’))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Personally I would try to avoid the if and simplifying it with something like this:&lt;/P&gt;&lt;P&gt;sum({&amp;lt;Year = {&lt;STRONG&gt;&lt;EM&gt;$(=max(Year) - 1)&lt;/EM&gt;&lt;/STRONG&gt;}&amp;gt;} [&lt;STRONG&gt;&lt;EM&gt;$(vKPISales)]&lt;/EM&gt;&lt;/STRONG&gt; )&lt;/P&gt;&lt;P&gt;Of course you need to ensure that your variable-values are exactly the same like your fieldnames.&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2019 13:57:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Issue-with-conditional-previous-year-expression/m-p/1570572#M442081</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2019-04-17T13:57:05Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with conditional previous year expression</title>
      <link>https://community.qlik.com/t5/QlikView/Issue-with-conditional-previous-year-expression/m-p/1570583#M442082</link>
      <description>Of course, how could I not see that? It solves Johan issue for sure!</description>
      <pubDate>Wed, 17 Apr 2019 14:05:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Issue-with-conditional-previous-year-expression/m-p/1570583#M442082</guid>
      <dc:creator>jaibau1993</dc:creator>
      <dc:date>2019-04-17T14:05:22Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with conditional previous year expression</title>
      <link>https://community.qlik.com/t5/QlikView/Issue-with-conditional-previous-year-expression/m-p/1570708#M442093</link>
      <description>&lt;P&gt;Hi and thanx for response&lt;/P&gt;&lt;P&gt;Unfortunately it didn't solve the issue. So, I've attached an example app.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The requirement is to present a table with Dimensions + a KPI field containing Value, Volume, Margin %... (with different number formattings) in the rows, and Actuals, Actuals last year, Budget, Budget last year.... in the columns.&lt;/P&gt;&lt;P&gt;If you select "Sales value" and 2019 in example app it gives correct 80 in total row for Last year, but shows N/A for Dim1 'B'. Instead of&amp;nbsp;N/A I would expect 30.&amp;nbsp;&lt;/P&gt;&lt;P&gt;BR/Johan&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2019 07:30:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Issue-with-conditional-previous-year-expression/m-p/1570708#M442093</guid>
      <dc:creator>lindbergkarlsta</dc:creator>
      <dc:date>2019-04-18T07:30:55Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with conditional previous year expression</title>
      <link>https://community.qlik.com/t5/QlikView/Issue-with-conditional-previous-year-expression/m-p/1570850#M442115</link>
      <description>&lt;P&gt;The cause is your selection of a year which is a regular field within your datamodel. There are of course possibilities within set analysis to bypass it but they could have also disadvantages - so it will always depend of all requirements which approach might be the most suitable. A common way to avoid some of these difficulties is to use for it also an extra field within an island table - similar like your measure field.&lt;/P&gt;&lt;P&gt;But like above mentioned I would do it a bit different by extending the measure table to the real fieldnames and also including the format. This means somethin like this one:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DynMeasures.JPG" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/10479i943446497E78BF7D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DynMeasures.JPG" alt="DynMeasures.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2019 08:13:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Issue-with-conditional-previous-year-expression/m-p/1570850#M442115</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2019-04-18T08:13:43Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with conditional previous year expression</title>
      <link>https://community.qlik.com/t5/QlikView/Issue-with-conditional-previous-year-expression/m-p/1570877#M442118</link>
      <description>&lt;P&gt;Thanx for your input Marcus, much appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;One core requirement is the ability to show&amp;nbsp;&lt;SPAN&gt;Value, Volume, Margin % in the same column at the same time. (My example app is just a slice of the actual app containing lots of measures which forms a P&amp;amp;L-like structure for Sales).&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;It seems that your version only works for one measure at a time, with "Always one selected value".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;As you wrote, it is my Year-filter that causes the issue. But I don't see why it works perfectly for current year and last year's total, but not for rows Last year if there is no data in current year.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Storing the real measure name and format in data island table instead of in variable is a good point.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;BR/Johan&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2019 09:04:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Issue-with-conditional-previous-year-expression/m-p/1570877#M442118</guid>
      <dc:creator>lindbergkarlsta</dc:creator>
      <dc:date>2019-04-18T09:04:57Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with conditional previous year expression</title>
      <link>https://community.qlik.com/t5/QlikView/Issue-with-conditional-previous-year-expression/m-p/1570956#M442125</link>
      <description>&lt;P&gt;Yes, your conclusion that my suggestion worked only with a single measure is correct. Because of the fact that Qlik doesn't provide an evaluate() function within the UI which could return valid fieldnames and/or expressions there is no way to use multiple different expressions within a measure unless they query the fieldvalues within conditions and branching then to the appropriate expression - quite similar to your nested if-loops.&lt;/P&gt;&lt;P&gt;Better than using the if-loops would be a pick(match()) like:&lt;/P&gt;&lt;P&gt;pick(match(Measure, 'A', 'B', 'C'),&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum(Field), avg(Field), sum(Field2))&lt;/P&gt;&lt;P&gt;whereby the measure- and the expression-list could in general be maintained and loaded from a table and called here with a concat() in a $-sign like:&lt;/P&gt;&lt;P&gt;pick(match(Measure, '$(=concat(MeasureList, chr(39) &amp;amp; ',' &amp;amp; chr(39)))'),&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum(Field), avg(Field), sum(Field2))&lt;/P&gt;&lt;P&gt;This is just an object-structure recommendation and independent from your selection-issue which needs to be handled through further set analysis in the expressions and/or adjustments within the datamodel (like the above mentioned island-tables, different table-structures, population from missing data, ...).&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2019 11:03:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Issue-with-conditional-previous-year-expression/m-p/1570956#M442125</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2019-04-18T11:03:39Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with conditional previous year expression</title>
      <link>https://community.qlik.com/t5/QlikView/Issue-with-conditional-previous-year-expression/m-p/1571538#M442167</link>
      <description>&lt;P&gt;Even if we didn't solve my core question you have confirmed there is no quick fix the way the logic is designed today. I will take the discussion with my customer what way to take from here.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanx again.&lt;/P&gt;&lt;P&gt;BR/Johan&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 21 Apr 2019 05:53:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Issue-with-conditional-previous-year-expression/m-p/1571538#M442167</guid>
      <dc:creator>lindbergkarlsta</dc:creator>
      <dc:date>2019-04-21T05:53:16Z</dc:date>
    </item>
  </channel>
</rss>

