<?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: Set expression to a long expression with multiple components in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Set-expression-to-a-long-expression-with-multiple-components/m-p/1301205#M831790</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One way could be to use variables with parameters, maybe in this way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;B = sum({$&amp;lt;retailyear={$1}&amp;gt;...)&lt;/P&gt;&lt;P&gt;C = count({$&amp;lt;retailyear={$1}&amp;gt;...)&lt;/P&gt;&lt;P&gt;D = avg({$&amp;lt;retailyear={$1}&amp;gt;...)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and then:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A = $(B(2016)) * $(C(2016)) / $(D(2016))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 16 Jun 2017 11:14:43 GMT</pubDate>
    <dc:creator>marcus_sommer</dc:creator>
    <dc:date>2017-06-16T11:14:43Z</dc:date>
    <item>
      <title>Set expression to a long expression with multiple components</title>
      <link>https://community.qlik.com/t5/QlikView/Set-expression-to-a-long-expression-with-multiple-components/m-p/1301202#M831787</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a model with four variables A, B, C, &lt;span class="lia-unicode-emoji" title=":anguished_face:"&gt;😧&lt;/span&gt;&lt;/P&gt;&lt;P&gt;A = B * C / D&lt;/P&gt;&lt;P&gt;where&lt;/P&gt;&lt;P&gt;B, C, D are all variables with long expression:&lt;/P&gt;&lt;P&gt;B = sum(...)&lt;/P&gt;&lt;P&gt;C = count(...)&lt;/P&gt;&lt;P&gt;D = avg(...)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I want is to apply a filter to calculate me A value of retail year 2016.&lt;/P&gt;&lt;P&gt;Below are two approaches I did:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;Approach 1:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;B_2016 = sum({$&amp;lt;retailyear={2016}&amp;gt; ...)&lt;/P&gt;&lt;P&gt;C_2016 = count&lt;SPAN style="font-size: 13.3333px;"&gt;({$&amp;lt;retailyear={2016}&amp;gt; ...)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;D_2016 = avg&lt;SPAN style="font-size: 13.3333px;"&gt;({$&amp;lt;retailyear={2016}&amp;gt; ...)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;A_2016 = $(B_2016) * $(C_2016) / $(D_2016)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;Approach 2:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;A_2016 = &lt;SPAN style="font-size: 13.3333px;"&gt;sum({$&amp;lt;retailyear={2016}&amp;gt; ...) * &lt;SPAN style="font-size: 13.3333px;"&gt;count&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;({$&amp;lt;retailyear={2016}&amp;gt; ...) / &lt;SPAN style="font-size: 13.3333px;"&gt;avg&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;({$&amp;lt;retailyear={2016}&amp;gt; ...)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Both approaches worked, but nasty: in Approach 1 I created too many variables, and in Approach 2 I created a extremely long and unreadable expression.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Is there a neat way, I can do something like:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;A_2016 = &lt;SPAN style="font-size: 13.3333px;"&gt;&amp;lt;retailyear={2016}&amp;gt; B * C / D&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Thank you!&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2020 16:16:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-expression-to-a-long-expression-with-multiple-components/m-p/1301202#M831787</guid>
      <dc:creator />
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Set expression to a long expression with multiple components</title>
      <link>https://community.qlik.com/t5/QlikView/Set-expression-to-a-long-expression-with-multiple-components/m-p/1301203#M831788</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try like:&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: 13.3333px;"&gt;A_2016 = &lt;STRONG&gt;Only&lt;/STRONG&gt;({&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;lt;retailyear={2016}&amp;gt;} &lt;STRONG&gt;Aggr&lt;/STRONG&gt;(B * C / D, retailyear))&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Jun 2017 08:34:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-expression-to-a-long-expression-with-multiple-components/m-p/1301203#M831788</guid>
      <dc:creator>tresB</dc:creator>
      <dc:date>2017-06-16T08:34:35Z</dc:date>
    </item>
    <item>
      <title>Re: Set expression to a long expression with multiple components</title>
      <link>https://community.qlik.com/t5/QlikView/Set-expression-to-a-long-expression-with-multiple-components/m-p/1301204#M831789</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you! It worked with a bit adjustment:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;A_2016 = &lt;STRONG style="font-style: inherit; font-size: 13.3333px; font-family: inherit;"&gt;Only&lt;/STRONG&gt;({&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;lt;retailyear={2016}&amp;gt;} &lt;STRONG style="font-style: inherit; font-size: 13.3333px; font-family: inherit;"&gt;Aggr&lt;/STRONG&gt;($(B) * $(C) / $(D), retailyear))&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Jun 2017 09:13:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-expression-to-a-long-expression-with-multiple-components/m-p/1301204#M831789</guid>
      <dc:creator />
      <dc:date>2017-06-16T09:13:03Z</dc:date>
    </item>
    <item>
      <title>Re: Set expression to a long expression with multiple components</title>
      <link>https://community.qlik.com/t5/QlikView/Set-expression-to-a-long-expression-with-multiple-components/m-p/1301205#M831790</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One way could be to use variables with parameters, maybe in this way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;B = sum({$&amp;lt;retailyear={$1}&amp;gt;...)&lt;/P&gt;&lt;P&gt;C = count({$&amp;lt;retailyear={$1}&amp;gt;...)&lt;/P&gt;&lt;P&gt;D = avg({$&amp;lt;retailyear={$1}&amp;gt;...)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and then:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A = $(B(2016)) * $(C(2016)) / $(D(2016))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Jun 2017 11:14:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-expression-to-a-long-expression-with-multiple-components/m-p/1301205#M831790</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2017-06-16T11:14:43Z</dc:date>
    </item>
  </channel>
</rss>

