<?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: Creating a Subtotal Table- Invalid Expression in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Creating-a-Subtotal-Table-Invalid-Expression/m-p/1317747#M408845</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This worked. I didn't really understand the function of Group By in this context, but I just searched some other threads and am starting to get the picture. Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 20 Jun 2017 11:50:08 GMT</pubDate>
    <dc:creator>jason_nicholas</dc:creator>
    <dc:date>2017-06-20T11:50:08Z</dc:date>
    <item>
      <title>Creating a Subtotal Table- Invalid Expression</title>
      <link>https://community.qlik.com/t5/QlikView/Creating-a-Subtotal-Table-Invalid-Expression/m-p/1317745#M408843</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to follow the suggestion in &lt;A _jive_internal="true" href="https://community.qlik.com/thread/98266"&gt;this post&lt;/A&gt;, but I am getting an error "Invalid Expression". Apologies, but I can't upload content.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Source data looks like:&lt;/P&gt;&lt;P&gt;Booking ID, Item, Item Amount&lt;/P&gt;&lt;P&gt;111, Item1, 100&lt;/P&gt;&lt;P&gt;111, Item2, 200&lt;/P&gt;&lt;P&gt;111, Discount, 30&lt;/P&gt;&lt;P&gt;123, Item1, 100&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and so on. Each entry (ID) might have a number of items, each with an associated cost. The discount amount also appears in the same data set as a positive number. First, to break the discount out from the rest of the items, I use the following in the primary fact table load script:&lt;/P&gt;&lt;P&gt;SourceTable:&lt;/P&gt;&lt;P&gt;LOAD [Booking ID],&lt;/P&gt;&lt;P&gt;if(match(Item, 'Discount'), [Item Amount]) as DiscountTemp,&lt;/P&gt;&lt;P&gt;if(not match(Item, 'Discount'), [Item Amount]) as Cost&lt;/P&gt;&lt;P&gt;FROM source&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Discount:&lt;/P&gt;&lt;P&gt;LOAD DISTINCT ([Booking ID]),&lt;/P&gt;&lt;P&gt;DiscountTemp as [Discount]&lt;/P&gt;&lt;P&gt;Resident SourceTable;&lt;/P&gt;&lt;P&gt;Drop Field DiscountTemp&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this gives me a table with the single discount entry associated with the Booking ID. Because any given ID would have either no discount, or only one single entry, this works perfectly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I want to create a variable to determine what percentage discount is applied per Booking ID. I want to subtotal all of the [Cost] values per [Booking ID] so that I can determine the discount percentage.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Per the linked thread, I created a resident table:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Subtotal:&lt;/P&gt;&lt;P&gt;LOAD DISTINCT ([Booking ID]),&lt;/P&gt;&lt;P&gt;sum(Cost) as Subtotal&lt;/P&gt;&lt;P&gt;Resident SourceTable;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I expect this to create a table just like the Discount table, but instead of the discount, the value should be the total of all other items in a Booking ID. I want to divide the Discount/Subtotal to create a percentage, which I want to be a variable to use throughout my charts. For my example above, I would want a subtotal of 300 for [Booking ID] 111, so that I can factor in the 30 discount, to create a variable of 10% as the discount total. Then, if I just look at 'Item 1' in a chart, the total cost should return as 90.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone explain my "Invalid Expression"? Are there better ways to do this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The reason for the whole effort is that, since the discount comes in as a lump sum and not as a percentage, I need to be able to accurately apply the discount to the cost per item when drilling down my charts. Right now, I can sum all costs, and subtract the discount so I get an accurate total for the whole [Booking ID], but when I select a single item, it would try to subtract the whole discount rather than just the portion applied to the item.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Jun 2017 18:56:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Creating-a-Subtotal-Table-Invalid-Expression/m-p/1317745#M408843</guid>
      <dc:creator>jason_nicholas</dc:creator>
      <dc:date>2017-06-19T18:56:25Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Subtotal Table- Invalid Expression</title>
      <link>https://community.qlik.com/t5/QlikView/Creating-a-Subtotal-Table-Invalid-Expression/m-p/1317746#M408844</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;STRONG&gt;Use group by clause&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;STRONG&gt;Subtotal:&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;STRONG&gt;LOAD DISTINCT ([Booking ID]),&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;STRONG&gt;sum(Cost) as Subtotal&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;STRONG&gt;Resident SourceTable&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;STRONG&gt;Group By &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;[Booking ID]&lt;/SPAN&gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Jun 2017 19:03:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Creating-a-Subtotal-Table-Invalid-Expression/m-p/1317746#M408844</guid>
      <dc:creator>aarkay29</dc:creator>
      <dc:date>2017-06-19T19:03:13Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Subtotal Table- Invalid Expression</title>
      <link>https://community.qlik.com/t5/QlikView/Creating-a-Subtotal-Table-Invalid-Expression/m-p/1317747#M408845</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This worked. I didn't really understand the function of Group By in this context, but I just searched some other threads and am starting to get the picture. Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jun 2017 11:50:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Creating-a-Subtotal-Table-Invalid-Expression/m-p/1317747#M408845</guid>
      <dc:creator>jason_nicholas</dc:creator>
      <dc:date>2017-06-20T11:50:08Z</dc:date>
    </item>
  </channel>
</rss>

