<?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: Help improve a query in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Help-improve-a-query/m-p/1670886#M727558</link>
    <description>&lt;P&gt;I think a bit more info can help with optimization.&lt;/P&gt;&lt;P&gt;How many rows of data do you get by just filtering on&amp;nbsp;&lt;SPAN&gt;KINAK &amp;lt;&amp;gt; 'Y'?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;How many rows of data did your original code get in the product table?&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 30 Jan 2020 13:09:20 GMT</pubDate>
    <dc:creator>MikeW</dc:creator>
    <dc:date>2020-01-30T13:09:20Z</dc:date>
    <item>
      <title>Help improve a query</title>
      <link>https://community.qlik.com/t5/QlikView/Help-improve-a-query/m-p/1670734#M727555</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Can Someone Please Help me to improve the following query?&lt;/P&gt;&lt;P&gt;The loading of the query is heavy and if I'm loading the query manually&amp;nbsp;and not through QMC I'm getting the error:&amp;nbsp;&lt;/P&gt;&lt;P&gt;"internal inconsistency type a"&lt;/P&gt;&lt;P&gt;&amp;nbsp;The amount of rows there is in ProductTemp QVD is:&amp;nbsp;363,704,000&lt;/P&gt;&lt;P&gt;Product:&lt;BR /&gt;LOAD&lt;BR /&gt;DocNum,&lt;BR /&gt;InvoiceNum,&lt;BR /&gt;InvoiceLine,&lt;BR /&gt;ZAEHK,&lt;BR /&gt;WebCode,&lt;BR /&gt;TPLST,&lt;BR /&gt;DeliveryNum,&lt;BR /&gt;SUM(if(KSCHL = 'Z130'AND KINAK &amp;lt;&amp;gt; 'M',KWERT)) as Discount1,&lt;BR /&gt;SUM(if(KSCHL = 'ZCO2'AND KINAK &amp;lt;&amp;gt; 'M',KWERT)) as Discount2 ,&lt;BR /&gt;SUM(if(MATCH(KSCHL,'ZCO5','ZCO3'),KWERT)) as DiSountOrder1,&lt;BR /&gt;SUM(if(KSCHL = 'ZAD1',KWERT)) as DiscountSale1,&lt;BR /&gt;SUM(if(MATCH(KSCHL,'ZAD2','HB00'),KWERT)) as DiscountSale2,&lt;BR /&gt;SUM(if(KSCHL = 'R100',KWERT)) as Discount100%,&lt;BR /&gt;SUM(if(MATCH(KSCHL,'PI02','ZPI2'),KWERT)) as Discount3,&lt;BR /&gt;SUM(if(MATCH(KSCHL,'PI01','ZPI1'),KWERT)) as FriendPrice,&lt;BR /&gt;SUM(if(KSCHL = 'ZCOS',KWERT)) as Discount4,&lt;BR /&gt;SUM(if(KSCHL = 'DIFF',KWERT)) as DiscountDiff,&lt;BR /&gt;SUM(if(MATCH(KSCHL,'ZBO3'),KWERT)) as Discount5,&lt;BR /&gt;SUM(if(KSCHL= 'ZE23',KWERT)) as Delivery,&lt;BR /&gt;SUM(if(KSCHL= 'ZE28',KWERT)) as Discount6,&lt;BR /&gt;SUM(if(KSCHL= 'ZE25',KWERT)) as Discount7,&lt;BR /&gt;SUM(if(KSCHL= 'ZE24',KWERT)) as Insurance,&lt;BR /&gt;SUM(if(KSCHL= 'ZE29',KWERT)) as Promotional,&lt;BR /&gt;SUM(if(KSCHL= 'ZV00',KWERT)) AS Product,&lt;BR /&gt;SUM(if(KSCHL= 'ZV10',KWERT)) AS Packaging,&lt;BR /&gt;SUM(if(KSCHL= 'ZV90',KWERT)) AS Contracting,&lt;BR /&gt;SUM(if(KSCHL= 'ZV15',KWERT)) AS Depreciation,&lt;BR /&gt;SUM(if(KSCHL= 'ZV60',KWERT)) AS Unfit,&lt;BR /&gt;SUM(if(KSCHL= 'ZV30',KWERT)) AS Permanentjob,&lt;BR /&gt;SUM(if(KSCHL= 'ZV05',KWERT)) AS Tempwork,&lt;BR /&gt;SUM(if(KSCHL= 'ZV40',KWERT)) AS MchinePermanent,&lt;BR /&gt;SUM(if(KSCHL= 'ZV45',KWERT)) AS TempMchine,&lt;BR /&gt;SUM(if(KSCHL= 'ZV70',KWERT)) AS TempDepreciation,&lt;BR /&gt;SUM(if(KSCHL= 'ZV80',KWERT)) AS Production,&lt;BR /&gt;SUM(if(KSCHL= 'Z120',KWERT)) AS Quantityofsalesinliters,&lt;BR /&gt;SUM(if(KSCHL= 'Z121',KWERT)) AS Quantityofsaleinkilograms,&lt;BR /&gt;SUM(if(KSCHL= 'Z110',KWERT)) AS QuantityofsaleinUnit,&lt;BR /&gt;SUM(if(KSCHL= 'Z100',KWERT)) AS Grosssales,&lt;BR /&gt;SUM(if(KSCHL= 'ZACR',KWERT)) AS Storage,&lt;BR /&gt;SUM(if([Material Type_MTART]='FERT' AND [Strategy group_STRGR]='82' and KSCHL= 'ZVPS',KWERT)) AS MixProduct,&lt;BR /&gt;SUM(if([Material Type_MTART]='FERT' AND [Strategy group_STRGR]='42' and KSCHL= 'ZVPS',KWERT)) AS MixCompany,&lt;BR /&gt;SUM(if(MATCH([Material Type_MTART],'PRFG','ROH','LABL','VERP','ZPRG') and KSCHL= 'ZVPS',KWERT)) AS TempProduct1,&lt;BR /&gt;SUM(if(KSCHL= 'ZPRS',KWERT)) AS Sellingcost&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;FROM ProductTemp.QVD (qvd)&lt;BR /&gt;Where KINAK &amp;lt;&amp;gt; 'Y'&lt;BR /&gt;GROUP BY DocNum,InvoiceNum,InvoiceLine,ZAEHK,WebCode,TPLST,DeliveryNum;&lt;/P&gt;&lt;P&gt;STORE Product into ProductFinal.QVD;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 16:16:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-improve-a-query/m-p/1670734#M727555</guid>
      <dc:creator>bellesol</dc:creator>
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Help improve a query</title>
      <link>https://community.qlik.com/t5/QlikView/Help-improve-a-query/m-p/1670739#M727556</link>
      <description>&lt;P&gt;I assume, This is the way how it is in the rules. But, Can't you use them in design or calculate in Source side?&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2020 07:39:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-improve-a-query/m-p/1670739#M727556</guid>
      <dc:creator>Anil_Babu_Samineni</dc:creator>
      <dc:date>2020-01-30T07:39:24Z</dc:date>
    </item>
    <item>
      <title>Re: Help improve a query</title>
      <link>https://community.qlik.com/t5/QlikView/Help-improve-a-query/m-p/1670767#M727557</link>
      <description>&lt;P&gt;If I understood your question correctly,&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are a few more QVW that are using the "FinalProducd" QVD in other queries&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2020 08:37:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-improve-a-query/m-p/1670767#M727557</guid>
      <dc:creator>bellesol</dc:creator>
      <dc:date>2020-01-30T08:37:34Z</dc:date>
    </item>
    <item>
      <title>Re: Help improve a query</title>
      <link>https://community.qlik.com/t5/QlikView/Help-improve-a-query/m-p/1670886#M727558</link>
      <description>&lt;P&gt;I think a bit more info can help with optimization.&lt;/P&gt;&lt;P&gt;How many rows of data do you get by just filtering on&amp;nbsp;&lt;SPAN&gt;KINAK &amp;lt;&amp;gt; 'Y'?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;How many rows of data did your original code get in the product table?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2020 13:09:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-improve-a-query/m-p/1670886#M727558</guid>
      <dc:creator>MikeW</dc:creator>
      <dc:date>2020-01-30T13:09:20Z</dc:date>
    </item>
    <item>
      <title>Re: Help improve a query</title>
      <link>https://community.qlik.com/t5/QlikView/Help-improve-a-query/m-p/1671009#M727559</link>
      <description>&lt;P&gt;Hi Bellesol,&lt;/P&gt;&lt;P&gt;I think the many Sum(If...) aggregations in your load script are very resource consuming. Try to use flags, instead.&lt;/P&gt;&lt;P&gt;This example for the two fields Delivery and&amp;nbsp;Discount6&lt;/P&gt;&lt;P&gt;T1:&lt;BR /&gt;LOAD&lt;BR /&gt;DocNum,&lt;BR /&gt;InvoiceNum,&lt;BR /&gt;InvoiceLine,&lt;BR /&gt;ZAEHK,&lt;BR /&gt;WebCode,&lt;BR /&gt;TPLST,&lt;BR /&gt;DeliveryNum,&lt;BR /&gt;KSCHL,&lt;BR /&gt;KWERT,&lt;BR /&gt;If(KSCHL = 'ZE23', 1, 0) as Flag_Delivery,&lt;BR /&gt;If(KSCHL = 'ZE28', 1, 0) as Flag_Discount6,&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;FROM ProductTemp.QVD (qvd)&lt;BR /&gt;Where KINAK &amp;lt;&amp;gt; 'Y'&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;In the next step you can use the summing aggregation like this:&lt;/P&gt;&lt;P&gt;Sum(KWERT *&amp;nbsp;Flag_Delivery) as&amp;nbsp;Delivery&lt;/P&gt;&lt;P&gt;This will be loaded way faster...&lt;/P&gt;&lt;P&gt;Hope this helps&lt;/P&gt;&lt;P&gt;Burkhard&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2020 17:00:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-improve-a-query/m-p/1671009#M727559</guid>
      <dc:creator>veidlburkhard</dc:creator>
      <dc:date>2020-01-30T17:00:04Z</dc:date>
    </item>
    <item>
      <title>Re: Help improve a query</title>
      <link>https://community.qlik.com/t5/QlikView/Help-improve-a-query/m-p/1671540#M727560</link>
      <description>&lt;P&gt;&lt;SPAN&gt;How many rows of data do you get by just filtering on&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;KINAK &amp;lt;&amp;gt; 'Y' -&amp;nbsp;266,161,021&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;How many rows of data did your original code get in the product table -&amp;nbsp;266,371,372&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Feb 2020 07:58:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-improve-a-query/m-p/1671540#M727560</guid>
      <dc:creator>bellesol</dc:creator>
      <dc:date>2020-02-02T07:58:09Z</dc:date>
    </item>
    <item>
      <title>Re: Help improve a query</title>
      <link>https://community.qlik.com/t5/QlikView/Help-improve-a-query/m-p/1671543#M727561</link>
      <description>&lt;P&gt;HI,&lt;/P&gt;&lt;P&gt;The problem is that I need to sum the results,&lt;/P&gt;&lt;P&gt;for example:&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;SUM(if(KSCHL= 'ZE23',KWERT)) as Delivery,&lt;/P&gt;&lt;P&gt;I need to sum the result of "KWERT" - it can be 100,200&lt;/P&gt;&lt;P&gt;an example for the data inside the table:&lt;/P&gt;&lt;TABLE width="1322"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="134"&gt;Material Type_MTART&lt;/TD&gt;&lt;TD width="140"&gt;Strategy group_STRGR&lt;/TD&gt;&lt;TD width="85"&gt;WebCode&lt;/TD&gt;&lt;TD width="76"&gt;ZAEHK&lt;/TD&gt;&lt;TD width="100"&gt;DocNum&lt;/TD&gt;&lt;TD width="90"&gt;InvoiceNum&lt;/TD&gt;&lt;TD width="90"&gt;DeliveryNum&lt;/TD&gt;&lt;TD width="117"&gt;TPLST&lt;/TD&gt;&lt;TD width="99"&gt;KSCHL&lt;/TD&gt;&lt;TD width="137"&gt;KWERT&lt;/TD&gt;&lt;TD width="97"&gt;InvoiceLine&lt;/TD&gt;&lt;TD width="157"&gt;KINAK&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;FERT&lt;/TD&gt;&lt;TD&gt;40&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;TD&gt;01&lt;/TD&gt;&lt;TD&gt;0015235795&lt;/TD&gt;&lt;TD&gt;0086325318&lt;/TD&gt;&lt;TD&gt;0000396278&lt;/TD&gt;&lt;TD&gt;1090&lt;/TD&gt;&lt;TD&gt;MWST&lt;/TD&gt;&lt;TD&gt;631.18&lt;/TD&gt;&lt;TD&gt;000020&lt;/TD&gt;&lt;TD&gt;X&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;FERT&lt;/TD&gt;&lt;TD&gt;40&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;TD&gt;01&lt;/TD&gt;&lt;TD&gt;0015212322&lt;/TD&gt;&lt;TD&gt;0086320334&lt;/TD&gt;&lt;TD&gt;0000396288&lt;/TD&gt;&lt;TD&gt;1000&lt;/TD&gt;&lt;TD&gt;DIFF&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;TD&gt;000010&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;FERT&lt;/TD&gt;&lt;TD&gt;52&lt;/TD&gt;&lt;TD&gt;300&lt;/TD&gt;&lt;TD&gt;01&lt;/TD&gt;&lt;TD&gt;0015212322&lt;/TD&gt;&lt;TD&gt;0086320331&lt;/TD&gt;&lt;TD&gt;0000396222&lt;/TD&gt;&lt;TD&gt;1000&lt;/TD&gt;&lt;TD&gt;DIFF&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;TD&gt;000010&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Feb 2020 09:16:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-improve-a-query/m-p/1671543#M727561</guid>
      <dc:creator>bellesol</dc:creator>
      <dc:date>2020-02-02T09:16:12Z</dc:date>
    </item>
    <item>
      <title>Re: Help improve a query</title>
      <link>https://community.qlik.com/t5/QlikView/Help-improve-a-query/m-p/1671547#M727562</link>
      <description>&lt;P&gt;... of course, you need summing!&lt;/P&gt;&lt;P&gt;But this should be the second step after building the flags.&lt;/P&gt;&lt;P&gt;In a new resident load with the new created flag your summing statement looks like this:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Noconcatenate&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;T2:&lt;BR /&gt;LOAD&lt;BR /&gt;DocNum,&lt;BR /&gt;InvoiceNum,&lt;BR /&gt;InvoiceLine,&lt;BR /&gt;ZAEHK,&lt;BR /&gt;WebCode,&lt;BR /&gt;TPLST,&lt;BR /&gt;DeliveryNum,&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;Sum(KWERT *&amp;nbsp;Flag_Delivery) as&amp;nbsp;Delivery,&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Resident T1&lt;BR /&gt;Group By&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;DocNum,&lt;BR /&gt;InvoiceNum,&lt;BR /&gt;InvoiceLine,&lt;BR /&gt;ZAEHK,&lt;BR /&gt;WebCode,&lt;BR /&gt;TPLST;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Drop Table T1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Happy qliking&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Burkhard&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Feb 2020 11:02:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-improve-a-query/m-p/1671547#M727562</guid>
      <dc:creator>veidlburkhard</dc:creator>
      <dc:date>2020-02-02T11:02:51Z</dc:date>
    </item>
    <item>
      <title>Re: Help improve a query</title>
      <link>https://community.qlik.com/t5/QlikView/Help-improve-a-query/m-p/1671553#M727563</link>
      <description>&lt;P&gt;The key to any task that is *heavy* is to follow a divide-and-conquer strategy.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So here is my first take on that:&lt;/P&gt;&lt;P&gt;1) Try to reduce the amount of data as much as possible from the outset - create the minimum viable subset of data you need for your analysis - by the most efficient way for your existing tool (QlikView LOAD statement in this case).&lt;/P&gt;&lt;P&gt;2) Consider the data model - do you need one single supertable as a result - you might not - as splitting the data between two or more tables might be more performant and efficient for QlikView.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;STEP 1:&lt;/P&gt;&lt;P&gt;Do an "optimized load" first - then you can't create any new fields or use a regular WHERE statement except a WHERE EXISTS(...).&lt;/P&gt;&lt;P&gt;So that would mean:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;COST_TYPE:
LOAD * INLINE [
KSCHL, CostType
Z130, Discount1
ZC02, Discount2
ZC05, DiSountOrder1
ZC03, DiSountOrder1
ZAD1, DiscountSale1
ZAD2, DiscountSale2
HB00, DiscountSale2
.... fill in the remaining 28 or so rows with KSCHL values and their costttype
];

PRODUCT_DIMENSIONS_AND_KWERT:
LOAD
  Docnum,
  InvoiceNum,
  InvoiceLine,
  ZAEHK,
  WebCode,
  TPLST,
  DeliveryNum,
  KSCHL,
  [Material Type_MTART],
  [Strategy group_STRGR],
  KINAK,
  KWERT
FROM
  ProductTemp.QVD(qvd)
WHERE
  Exists(KSCHL);
// I hope that this will have brought down the number of rows to a decent level

STORE PRODUCT_DIMENSIONS_AND_KWERT INTO Product_Dimensions_and_KWERT.QVD (qvd);

DROP TABLE PRODUCT_DIMENSIONS_AND_KWERT;

KINAK_FILTER:
LOAD * INLINE [
KINAK
Y
];

PRODUCT_DIMENSION_AND_KWERT:
LOAD 
  * 
FROM 
  PRODUCT_DIMENSIONS_AND_KWERT FROM Product_Dimensions_and_KWERT.QVD (qvd) 
WHERE 
  Not(Exists(KINAK));

STORE PRODUCT_DIMENSIONS_AND_KWERT INTO Product_Dimensions_and_KWERT.QVD (qvd);

// Now you have two tables, the COST_TYPE and PRODUCT_DIMENSIONS_AND_KWERT
// This might be a sufficent data model. However it can be further refined 
// and it MIGHT give better performance by doing the following steps:

DROP TABLE PRODUCT_DIMENSIONS_AND_KWERT;


PRODUCT_DIMENSIONS:
LOAD DISTINCT
  Docnum,
  InvoiceNum,
  InvoiceLine,
  ZAEHK,
  WebCode,
  TPLST,
  DeliveryNum,
  KSCHL,
  [Material Type_MTART],
  [Strategy group_STRGR],
  AutoNumber(
    Docnum &amp;amp; '|'
    InvoiceNum &amp;amp; '|'
    InvoiceLine &amp;amp; '|'
    ZAEHK &amp;amp; '|'
    WebCode &amp;amp; '|'
    TPLST &amp;amp; '|'
    DeliveryNum &amp;amp; '|'
    KSCHL &amp;amp; '|'
    [Material Type_MTART] &amp;amp; '|'
    [Strategy group_STRGR],
    'PROD_DIMS_KEY'
  ) AS %ProdDims	
FROM
  Product_Dimensions_and_KWERT.QVD (qvd);
  
METRICS:
LOAD
  AutoNumber(
    Docnum &amp;amp; '|'
    InvoiceNum &amp;amp; '|'
    InvoiceLine &amp;amp; '|'
    ZAEHK &amp;amp; '|'
    WebCode &amp;amp; '|'
    TPLST &amp;amp; '|'
    DeliveryNum &amp;amp; '|'
    KSCHL &amp;amp; '|'
    [Material Type_MTART] &amp;amp; '|'
    [Strategy group_STRGR],
    'PROD_DIMS_KEY'
  ) AS %ProdDims,
  KWERT
FROM
  Product_Dimensions_and_KWERT.QVD (qvd);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In your UI you can calculate any particular cost type by having an expression like this using "Set Analysis" (it is really a set expression):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sum( { &amp;lt;CostType={Discount1}&amp;gt; KWERT)&lt;/P&gt;&lt;P&gt;and in a Filter Pane your could also select the CostType more dynamically by just selecting which cost type to calculate.&lt;/P&gt;&lt;P&gt;Sum( {&amp;lt;CostType={MixProduct},[Material Type_MTART]={FERT},[Strategy group_STRGR]={82}&amp;gt;} KWERT)&lt;/P&gt;&lt;P&gt;In the case of the more composite classifications.&lt;BR /&gt;&lt;BR /&gt;___________________________________________________________________&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;To make it even more "complete" and clean as a data model&lt;/STRONG&gt; and include the composite classifications you could&amp;nbsp;evolve the COST_TYPE table by following this approach:&lt;/P&gt;&lt;P&gt;You will have to refine the PRODUCT_TYPE table with three additional fields; [Material Type_MTART], [Strategy group_STRGR] and an AutoNumber([Mater...]&amp;amp;'|'&amp;amp;[Strat...],'PROD_TYPE_KEY') AS %ProdType (in both the COST_TYPE and PRODUCTION_DIMENSIONS table) and call the KSCHL field in the COST_TYPE table something like KSCHL_ (to avoid a synthetic key being generated by Qlik).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This is basically similar to the way that has already been done between the METRICS and PRODUCT_DIMENSIONS table...&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Feb 2020 13:27:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-improve-a-query/m-p/1671553#M727563</guid>
      <dc:creator>petter</dc:creator>
      <dc:date>2020-02-02T13:27:29Z</dc:date>
    </item>
    <item>
      <title>Re: Help improve a query</title>
      <link>https://community.qlik.com/t5/QlikView/Help-improve-a-query/m-p/1671584#M727564</link>
      <description>&lt;P&gt;The "internal inconsistency type a" happens when the machine you are doing the reload on runs out of memory. The QMC publisher might have more memory than the machine you are trying to manually reload on. While the query can be optimized, it might still not run if your computer does not have enough memory.&lt;/P&gt;&lt;P&gt;There are many ways to improve the data model for performance if you consider how the result is used later on. Since you said the ProductFinal.QVD is used somewhere else and without knowing how it gets used, I can suggest just doing filter on KINAK here and IF(...,KWRT,0) without SUM() or Group By.&lt;/P&gt;&lt;P&gt;The Load script would then be:&lt;/P&gt;&lt;P&gt;PRODUCT:&lt;BR /&gt;LOAD&lt;BR /&gt;&amp;nbsp; &amp;nbsp; DocNum,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; InvoiceNum,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; InvoiceLine,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; ZAEHK,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; WebCode,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; TPLST,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; DeliveryNum,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if(KSCHL = 'Z130'AND KINAK &amp;lt;&amp;gt; 'M',KWERT,0) as Discount1,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; ...&lt;BR /&gt;FROM ProductTemp.QVD (qvd)&lt;BR /&gt;Where KINAK &amp;lt;&amp;gt; 'Y'&lt;BR /&gt;STORE Product into ProductFinal.QVD;&lt;/P&gt;&lt;P&gt;Some explanations:&lt;BR /&gt;Group Bys are bottlenecked by a single threaded component - I think Qlik just sucks at doing this in general. It is not worth doing unless you expect to reduce the rows by more than 100x. Your data in and out of the group by has essentially the same number of rows, so it is useless.&lt;/P&gt;&lt;P&gt;Of course if you are allowed to change more downstream processes where the results are used, then you can use further optimization methods like others have suggested.&lt;/P&gt;</description>
      <pubDate>Sun, 02 Feb 2020 19:13:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-improve-a-query/m-p/1671584#M727564</guid>
      <dc:creator>MikeW</dc:creator>
      <dc:date>2020-02-02T19:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: Help improve a query</title>
      <link>https://community.qlik.com/t5/QlikView/Help-improve-a-query/m-p/1678735#M727565</link>
      <description>&lt;P&gt;Did any of the posts help you with the optimization?&amp;nbsp; If so, please be sure to circle back to this thread and use the Accept as Solution button on any that did to close out the thread, so folks will know no further suggestions are necessary.&amp;nbsp; If you did something different, please post that and mark it as the solution.&amp;nbsp; If you still have questions, please leave an update based upon all the provided suggestions.&lt;/P&gt;
&lt;P&gt;The last post regarding the Exception was spot-on too, that is a memory related condition, you should be able to use the Script Debugger to limit the number of rows to prove this theory, if you restrict things to 100 M for instance and everything works, that will more or less confirm you have a resource issue on your local machine.&amp;nbsp; I am not much help otherwise on this one unfortunately, you have most of the sites I have given you in other posts to look for further help there...&lt;/P&gt;
&lt;P&gt;Regards,&lt;BR /&gt;Brett&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2020 20:04:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-improve-a-query/m-p/1678735#M727565</guid>
      <dc:creator>Brett_Bleess</dc:creator>
      <dc:date>2020-02-24T20:04:35Z</dc:date>
    </item>
  </channel>
</rss>

