<?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: Expression Help in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Expression-Help/m-p/740396#M10639</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It can work with a conditional expression as long as the result of the expression is an aggregation expression ( sum() in this case). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not sure why it's not working for you.&amp;nbsp; Would you like to post the .qvf file ? Likely some subtle differences in my sample and your sample that need some drilling into&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 24 Feb 2015 11:41:13 GMT</pubDate>
    <dc:creator>JonnyPoole</dc:creator>
    <dc:date>2015-02-24T11:41:13Z</dc:date>
    <item>
      <title>Expression Help</title>
      <link>https://community.qlik.com/t5/App-Development/Expression-Help/m-p/740390#M10633</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have an expression:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SUM( {1} if(OrderBTL &amp;gt;= 2, if(OrderBTR &amp;lt;= 9, Amount)))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;that gives me the exact result that I want, except I would like to replace the constants (2 &amp;amp; 9) with fields from the currently selected set. For 2 I would like to use the field called [left] and for 9 I would like to use the field called &lt;/P&gt;&lt;P align="right"&gt;. I have tried a number of different things but have been unable to get it right.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I realize that this expression will only be evaluated once for the sheet,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am open to suggestions for improvement as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;John&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Feb 2015 15:44:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Expression-Help/m-p/740390#M10633</guid>
      <dc:creator />
      <dc:date>2015-02-17T15:44:25Z</dc:date>
    </item>
    <item>
      <title>Re: Expression Help</title>
      <link>https://community.qlik.com/t5/App-Development/Expression-Help/m-p/740391#M10634</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do the fields called [left] and [right] have multiple values ?&amp;nbsp; Sounds like they user would have to select a value from those first , &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The only() function will only evaluate the condition if there is one possible value. it may work for you...&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: 13px;"&gt;SUM( {1} if(OrderBTL &amp;gt;= only([left])&amp;nbsp; and OrderBTR &amp;lt;= only(&lt;/SPAN&gt;&lt;/P&gt;&lt;P align="right"&gt;) , Amount))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Feb 2015 03:06:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Expression-Help/m-p/740391#M10634</guid>
      <dc:creator>JonnyPoole</dc:creator>
      <dc:date>2015-02-19T03:06:08Z</dc:date>
    </item>
    <item>
      <title>Re: Expression Help</title>
      <link>https://community.qlik.com/t5/App-Development/Expression-Help/m-p/740392#M10635</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your response. [left] and [right] have a single value based on the active context.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried your suggestion:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SUM( {1} if(OrderBTL &amp;gt;= only([left]), if(OrderBTR &amp;lt;= only(&lt;/P&gt;&lt;P align="right"&gt;), Amount)))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The expression editor displays "Error in Expression: Nested aggregation not allowed".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any other thoughts?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;John&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Feb 2015 16:35:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Expression-Help/m-p/740392#M10635</guid>
      <dc:creator />
      <dc:date>2015-02-19T16:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: Expression Help</title>
      <link>https://community.qlik.com/t5/App-Development/Expression-Help/m-p/740393#M10636</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Of course ! my bad.&amp;nbsp; nested aggregations will never work unless with aggr() .&amp;nbsp; Let me check into an alternative&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Feb 2015 16:58:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Expression-Help/m-p/740393#M10636</guid>
      <dc:creator>JonnyPoole</dc:creator>
      <dc:date>2015-02-19T16:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: Expression Help</title>
      <link>https://community.qlik.com/t5/App-Development/Expression-Help/m-p/740394#M10637</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This may work better. but i'm not sure if you need a sum(Sales) or a sum( {1} Sales) in the scenario within the IF&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SUM( {1} aggr( if(OrderID &amp;gt;= only(left) and OrderID &amp;lt;= only(right), sum(&amp;nbsp; Sales)),OrderID))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know if you get what you rwant.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Feb 2015 17:25:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Expression-Help/m-p/740394#M10637</guid>
      <dc:creator>JonnyPoole</dc:creator>
      <dc:date>2015-02-19T17:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: Expression Help</title>
      <link>https://community.qlik.com/t5/App-Development/Expression-Help/m-p/740395#M10638</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the attempt, but you lost me on how you are using the aggr function. My understanding of aggr() was that it accepts the aggregation function as the first parameter, so I don't really understand what having the if() as the first parameter means.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That being said, I tried a few variations on this:&lt;/P&gt;&lt;P&gt;SUM( {1} aggr( if(OrderBTL &amp;gt;= only(left) and OrderBTR &amp;lt;= only(right), sum( {1} Amount)),OrderNum))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But they all returned no value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;John&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Feb 2015 23:18:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Expression-Help/m-p/740395#M10638</guid>
      <dc:creator />
      <dc:date>2015-02-19T23:18:39Z</dc:date>
    </item>
    <item>
      <title>Re: Expression Help</title>
      <link>https://community.qlik.com/t5/App-Development/Expression-Help/m-p/740396#M10639</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It can work with a conditional expression as long as the result of the expression is an aggregation expression ( sum() in this case). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not sure why it's not working for you.&amp;nbsp; Would you like to post the .qvf file ? Likely some subtle differences in my sample and your sample that need some drilling into&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Feb 2015 11:41:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Expression-Help/m-p/740396#M10639</guid>
      <dc:creator>JonnyPoole</dc:creator>
      <dc:date>2015-02-24T11:41:13Z</dc:date>
    </item>
    <item>
      <title>Re: Expression Help</title>
      <link>https://community.qlik.com/t5/App-Development/Expression-Help/m-p/740397#M10640</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jonathan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have attached the .qvf file and a .txt file that (I hope) explains the situation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I appreciate all your help so far. Hopefully we can work this one out!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Feb 2015 19:33:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Expression-Help/m-p/740397#M10640</guid>
      <dc:creator />
      <dc:date>2015-02-24T19:33:42Z</dc:date>
    </item>
    <item>
      <title>Re: Expression Help</title>
      <link>https://community.qlik.com/t5/App-Development/Expression-Help/m-p/740398#M10641</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The QVF as is seems to work for Bill, both left and right numbers.&amp;nbsp; When i get down to kate or john though, its summing up the selected names orders as well. For example, when i select kate and left, it gives me johns numbers (good) but also kates numbers (bad). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This tells me the expression is fine but there is something wrong with the associations between the names and the order amounts. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That seems to be proved out below where there is a table that shows the raw associated values coming &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Untitled.png" class="image-1 jive-image" src="https://community.qlik.com/legacyfs/online/79024_Untitled.png" style="height: 246px; width: 620px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If i add left and right as list boxes, i can see that there are actually 2 left and right values ... which one should be used for the calculation ?&amp;nbsp;&amp;nbsp; I'm not sure but i sense a data model issue. The hierarchy should be able to take care of the correct joining&amp;nbsp; to the order table at the different nodes , but at a glance i couldn't guess what the rest of the ETL script is attempting to do. I sense you are trying to create a left and right attribute for each node but something is off, its not consistent. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Capture.PNG" class="jive-image image-2" src="https://community.qlik.com/legacyfs/online/79031_Capture.PNG" style="height: 253px; width: 620px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Feb 2015 01:30:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Expression-Help/m-p/740398#M10641</guid>
      <dc:creator>JonnyPoole</dc:creator>
      <dc:date>2015-02-25T01:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: Expression Help</title>
      <link>https://community.qlik.com/t5/App-Development/Expression-Help/m-p/740399#M10642</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for continuing to investigate this with me and for your patience.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The reason there are multiple left and right values is related to how Qlik builds hierarchies with levels.&amp;nbsp; An addition filter of Level=1 needs to be applied to get the correct left and right values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I took your thought of there being a data model issue to heart and created another sample app that just uses LOAD INLINE to load the data correctly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using this new app I am still unable to get the correct answer without hard coding specific left and right numbers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can I inconvenience you one more time to take a look and suggest a solution?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;John&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Feb 2015 14:07:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Expression-Help/m-p/740399#M10642</guid>
      <dc:creator />
      <dc:date>2015-02-26T14:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: Expression Help</title>
      <link>https://community.qlik.com/t5/App-Development/Expression-Help/m-p/740400#M10643</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe this is closer:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------&lt;/P&gt;&lt;P&gt;PeopleTemp:&lt;/P&gt;&lt;P&gt;HierarchyBelongsTo(PersonKey, ParentKey, Name, AncestorID, AncestorName, DepthDiff)&amp;nbsp; LOAD * INLINE [&lt;/P&gt;&lt;P&gt;&amp;nbsp; PersonKey,ParentKey, Name, ChildBranch&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1,,'Bobby'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2,1,'Bill','Left'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3,1,'Peter','Right'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4,2,'Kate','Left'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5,2,'Lloyd','Right'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6,4,'John','Left'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7,3,'Gino','Left'&lt;/P&gt;&lt;P&gt;];&lt;/P&gt;&lt;P&gt;// PersonKey,ParentKey, Name, Branch&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;People:&lt;/P&gt;&lt;P&gt;Load * , if(PersonKey=AncestorID,'Current Node','Children') as AggregationType&lt;/P&gt;&lt;P&gt;resident PeopleTemp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;drop table PeopleTemp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Orders:&lt;/P&gt;&lt;P&gt;LOAD * INLINE [&lt;/P&gt;&lt;P&gt;&amp;nbsp; OrderNum, PersonKey, Amount, OrderLeft, OrderRight&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1,6,100,4,5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2,6,100,4,5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3,6,100,4,5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4,7,500,11,12&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5,3,250,12,13&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6,4,150,3,6&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;IMG alt="Capture.PNG" class="image-1 jive-image" src="https://community.qlik.com/legacyfs/online/79454_Capture.PNG" style="height: 280px; width: 620px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Feb 2015 16:43:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Expression-Help/m-p/740400#M10643</guid>
      <dc:creator>JonnyPoole</dc:creator>
      <dc:date>2015-02-27T16:43:53Z</dc:date>
    </item>
    <item>
      <title>Re: Expression Help</title>
      <link>https://community.qlik.com/t5/App-Development/Expression-Help/m-p/740401#M10644</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Was this of any help&amp;nbsp; ?&amp;nbsp; I liked the post because it brought an angle that was new to me with respect to hierarchies, that is, a hierarchy with just 2 branches (left and right) at each node and how best to reflect that attribute in the hierarchy load.&amp;nbsp; I did feel the expression and load script i presented resolved the situation but the one piece that would need to be customized is to transform the data into a format that i used in my hierarchybelongsto load.&amp;nbsp; anyways , it was interesting so if you get back to this i'd love to hear how things turned out.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2015 02:18:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Expression-Help/m-p/740401#M10644</guid>
      <dc:creator>JonnyPoole</dc:creator>
      <dc:date>2015-03-04T02:18:35Z</dc:date>
    </item>
    <item>
      <title>Re: Expression Help</title>
      <link>https://community.qlik.com/t5/App-Development/Expression-Help/m-p/740402#M10645</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I haven’t had a chance to try it out yet, but I will in the next day or so.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I’m glad I was able to challenge you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2015 20:53:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Expression-Help/m-p/740402#M10645</guid>
      <dc:creator />
      <dc:date>2015-03-04T20:53:59Z</dc:date>
    </item>
    <item>
      <title>Re: Expression Help</title>
      <link>https://community.qlik.com/t5/App-Development/Expression-Help/m-p/740403#M10646</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jonathan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;your solution appears to work but for only 1 level down in the tree.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example, if I choose "Bobby" and "Right" it shows 250, but it should show 750 (Peter's 250 + Gino's 500).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I believe the example works for "Bill" and "Left" because both Kate and John are on the left side. If we were to move John to Kate's right side I bet it will not work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again for the attempt. Your approach has given me something else to think about as I work towards a solution.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Mar 2015 14:24:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Expression-Help/m-p/740403#M10646</guid>
      <dc:creator />
      <dc:date>2015-03-11T14:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: Expression Help</title>
      <link>https://community.qlik.com/t5/App-Development/Expression-Help/m-p/740404#M10647</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;John - i see exaclty what you are referring to.&amp;nbsp; The left/right branch field propogates to all children giving you not only the left branch children but the left branch of those children too (grandchildren) which is wrong for this need.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I'm thinking another attribute is needed to differentiate children vs grandchildren.&amp;nbsp; I'll take another crack at this when i have some cycles.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Mar 2015 14:33:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Expression-Help/m-p/740404#M10647</guid>
      <dc:creator>JonnyPoole</dc:creator>
      <dc:date>2015-03-12T14:33:47Z</dc:date>
    </item>
  </channel>
</rss>

