<?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 Expression as a Variable in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Expression-as-a-Variable/m-p/234873#M587770</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you have two basic mistakes in your expression. First, correct, you can't use [Position] if it is just a named expression in a chart. You have to recalculate it in your new expression. For simplicity, I'm going to assume your expression is If(Rand()&amp;gt;.5,'LONG','SHORT'), which obviously it isn't. Substitute your own expression of course. Second, when you aggr(), you need to tell it what dimensions you want to aggregate by, in this case, Group and Currency. So I think you want something like this:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;Sum(Aggr(If(Match(Group,'OTH'),If(&lt;STRONG&gt;If(Rand()&amp;gt;.5,'LONG','SHORT')&lt;/STRONG&gt;='LONG',Sum(YTD_CV)))&lt;STRONG&gt;,Group,Currency&lt;/STRONG&gt;))/1000&lt;/P&gt;&lt;P&gt;Now, this particular example could be further simplified, but I wanted to directly use your existing expressions. Feel free to simplify from there.&lt;/P&gt;&lt;P&gt;If the expression for short or long is too big, consider making IT a variable, and using it in both places.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 30 Dec 2010 02:11:58 GMT</pubDate>
    <dc:creator>johnw</dc:creator>
    <dc:date>2010-12-30T02:11:58Z</dc:date>
    <item>
      <title>Expression as a Variable</title>
      <link>https://community.qlik.com/t5/QlikView/Expression-as-a-Variable/m-p/234870#M587767</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I have a pivot table in which i have used the following expression,&lt;/P&gt;&lt;P&gt;If (&lt;B&gt;Match&lt;/B&gt;(&lt;B&gt;Group&lt;/B&gt;,'OTH'),&lt;B&gt;If&lt;/B&gt;(&lt;B&gt;[Position]&lt;/B&gt;='LONG',&lt;B&gt;Sum&lt;/B&gt;(&lt;B&gt;YTD_CV&lt;/B&gt;)))/ 1000&lt;/P&gt;&lt;P&gt;So i get this result;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="error loading image" class="jive-image error-loading-image" src="https://community.qlik.com/legacyfs/online/-3144_sourceID:3144" /&gt;&lt;/P&gt;&lt;P&gt;I get the result i need in the red box.&lt;/P&gt;&lt;P&gt;Now, however, I need to use the total - 12,958 as a variable so that it can be used in other tables.&lt;/P&gt;&lt;P&gt;I tried using the following;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;Sum&lt;/B&gt;(&lt;B&gt;Aggr&lt;/B&gt;(&lt;B&gt;If&lt;/B&gt;(&lt;B&gt;Match&lt;/B&gt;(&lt;B&gt;Group&lt;/B&gt;,'OTH'),&lt;B&gt;If&lt;/B&gt;(&lt;B&gt;[Position]&lt;/B&gt;='LONG',&lt;B&gt;Sum&lt;/B&gt;(&lt;B&gt;YTD_CV&lt;/B&gt;)))))/1000 but it displays a null value.&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Can someone help here?&lt;/P&gt;&lt;P&gt;PS. I cannot post a sample since I open the file in server mode.&lt;/P&gt;&lt;P&gt;King Regards,&lt;/P&gt;&lt;P&gt;M.K.S&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Dec 2010 08:35:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Expression-as-a-Variable/m-p/234870#M587767</guid>
      <dc:creator />
      <dc:date>2010-12-29T08:35:25Z</dc:date>
    </item>
    <item>
      <title>Expression as a Variable</title>
      <link>https://community.qlik.com/t5/QlikView/Expression-as-a-Variable/m-p/234871#M587768</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;You can instead use&lt;/P&gt;&lt;P&gt;if(Group='OTH' and Position='LONG',Sum(Total&amp;lt;Group&amp;gt; YTD_CV ))/1000&lt;/P&gt;&lt;P&gt;It will give you the Sum(YTD_CV) aggregated on Group.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Dec 2010 08:51:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Expression-as-a-Variable/m-p/234871#M587768</guid>
      <dc:creator>syed_muzammil</dc:creator>
      <dc:date>2010-12-29T08:51:34Z</dc:date>
    </item>
    <item>
      <title>Expression as a Variable</title>
      <link>https://community.qlik.com/t5/QlikView/Expression-as-a-Variable/m-p/234872#M587769</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Syed,&lt;/P&gt;&lt;P&gt;Thanks for your reply, if i use the formula you suggested it still doesnt work, i think its because the Position in the expression is caluclated using other calculated expressions from the pivot table/. I cannot write the whole formula since it is too long.&lt;/P&gt;&lt;P&gt;I just need to use the total of the column as a variable because i need to use it for calculation in another table/chart.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Dec 2010 09:16:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Expression-as-a-Variable/m-p/234872#M587769</guid>
      <dc:creator />
      <dc:date>2010-12-29T09:16:46Z</dc:date>
    </item>
    <item>
      <title>Expression as a Variable</title>
      <link>https://community.qlik.com/t5/QlikView/Expression-as-a-Variable/m-p/234873#M587770</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you have two basic mistakes in your expression. First, correct, you can't use [Position] if it is just a named expression in a chart. You have to recalculate it in your new expression. For simplicity, I'm going to assume your expression is If(Rand()&amp;gt;.5,'LONG','SHORT'), which obviously it isn't. Substitute your own expression of course. Second, when you aggr(), you need to tell it what dimensions you want to aggregate by, in this case, Group and Currency. So I think you want something like this:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;Sum(Aggr(If(Match(Group,'OTH'),If(&lt;STRONG&gt;If(Rand()&amp;gt;.5,'LONG','SHORT')&lt;/STRONG&gt;='LONG',Sum(YTD_CV)))&lt;STRONG&gt;,Group,Currency&lt;/STRONG&gt;))/1000&lt;/P&gt;&lt;P&gt;Now, this particular example could be further simplified, but I wanted to directly use your existing expressions. Feel free to simplify from there.&lt;/P&gt;&lt;P&gt;If the expression for short or long is too big, consider making IT a variable, and using it in both places.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Dec 2010 02:11:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Expression-as-a-Variable/m-p/234873#M587770</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2010-12-30T02:11:58Z</dc:date>
    </item>
    <item>
      <title>Expression as a Variable</title>
      <link>https://community.qlik.com/t5/QlikView/Expression-as-a-Variable/m-p/234874#M587771</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks John for your reply. I havent had a chance to try out your suggestions but will post a reply with the results once i've tested it out.&lt;/P&gt;&lt;P&gt;Many Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Jan 2011 12:51:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Expression-as-a-Variable/m-p/234874#M587771</guid>
      <dc:creator />
      <dc:date>2011-01-03T12:51:53Z</dc:date>
    </item>
  </channel>
</rss>

