<?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 Table join and group by problem in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Table-join-and-group-by-problem/m-p/2498607#M1226314</link>
    <description>&lt;P&gt;&lt;SPAN&gt;First of all, hello everyone.&amp;nbsp;I'm new to Qlik and&amp;nbsp;I couldn't get out of the problem inside. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I have one table: &lt;STRONG&gt;Fact.&lt;/STRONG&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Then I created&amp;nbsp;the &lt;STRONG&gt;Transaction_Number&lt;/STRONG&gt; table and added two sum fields using group by and it worked at first.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;However, when I use a date filter on the chart, the calculations do not work correctly because I cannot create a key between the two tables.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;When I create a unique key as follows and add it both tables, I get an "&lt;STRONG&gt;invalid expression"&lt;/STRONG&gt; error.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;(Region Code"&amp;amp;'_'&amp;amp;"Branch Code"&amp;amp;'_'&amp;amp;"Completed + Cancel" as %KEY)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Moreover, while I want the group by command to be applied only to fields that contains &lt;STRONG&gt;sum&lt;/STRONG&gt;, but it also applies group by to other fields I add to the table, and the calculation gets confused.&lt;/P&gt;
&lt;P&gt;Here is the code. I request your kind help.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;FACT:&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;LOAD&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Year("Transaction Period") as Year,&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Month("Transaction Period") as Month,&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Date(MakeDate(Year("Transaction Period") ,num(Month("Transaction Period")), 'YYYY.MM') as Period,&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Region code",&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Branch Code",&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Branch Name",&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Region Name"&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Section Name",&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Process Name"&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Total Refund",&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Completed + Cancel",&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Return Rate"&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;FROM [………………………………);&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;TRANSACTION_NUMBER:&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;LOAD&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Sum("Completed + Cancel") as Number of Transactions,&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Sum("Total Refund")/Sum("Completed + Cancel") as Refund_Rate&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Resident FACT&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Group by "Region Name"&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;;&lt;/EM&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 18 Dec 2024 14:04:39 GMT</pubDate>
    <dc:creator>Fight4Freedom</dc:creator>
    <dc:date>2024-12-18T14:04:39Z</dc:date>
    <item>
      <title>Table join and group by problem</title>
      <link>https://community.qlik.com/t5/QlikView/Table-join-and-group-by-problem/m-p/2498607#M1226314</link>
      <description>&lt;P&gt;&lt;SPAN&gt;First of all, hello everyone.&amp;nbsp;I'm new to Qlik and&amp;nbsp;I couldn't get out of the problem inside. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I have one table: &lt;STRONG&gt;Fact.&lt;/STRONG&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Then I created&amp;nbsp;the &lt;STRONG&gt;Transaction_Number&lt;/STRONG&gt; table and added two sum fields using group by and it worked at first.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;However, when I use a date filter on the chart, the calculations do not work correctly because I cannot create a key between the two tables.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;When I create a unique key as follows and add it both tables, I get an "&lt;STRONG&gt;invalid expression"&lt;/STRONG&gt; error.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;(Region Code"&amp;amp;'_'&amp;amp;"Branch Code"&amp;amp;'_'&amp;amp;"Completed + Cancel" as %KEY)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Moreover, while I want the group by command to be applied only to fields that contains &lt;STRONG&gt;sum&lt;/STRONG&gt;, but it also applies group by to other fields I add to the table, and the calculation gets confused.&lt;/P&gt;
&lt;P&gt;Here is the code. I request your kind help.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;FACT:&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;LOAD&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Year("Transaction Period") as Year,&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Month("Transaction Period") as Month,&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Date(MakeDate(Year("Transaction Period") ,num(Month("Transaction Period")), 'YYYY.MM') as Period,&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Region code",&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Branch Code",&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Branch Name",&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Region Name"&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Section Name",&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Process Name"&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Total Refund",&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Completed + Cancel",&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Return Rate"&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;FROM [………………………………);&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;TRANSACTION_NUMBER:&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;LOAD&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Sum("Completed + Cancel") as Number of Transactions,&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Sum("Total Refund")/Sum("Completed + Cancel") as Refund_Rate&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Resident FACT&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Group by "Region Name"&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2024 14:04:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Table-join-and-group-by-problem/m-p/2498607#M1226314</guid>
      <dc:creator>Fight4Freedom</dc:creator>
      <dc:date>2024-12-18T14:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: Table join and group by problem</title>
      <link>https://community.qlik.com/t5/QlikView/Table-join-and-group-by-problem/m-p/2498611#M1226315</link>
      <description>&lt;P&gt;You need to include the grouping-fields also within the aggregation load because otherwise you creates just one global value - in your case in may look like:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;LOAD &lt;STRONG&gt;Key&lt;/STRONG&gt;,&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Sum("Completed + Cancel") as Number of Transactions,&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Sum("Total Refund")/Sum("Completed + Cancel") as Refund_Rate&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Resident FACT&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Group by "&lt;STRONG&gt;Key&lt;/STRONG&gt;"&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Beside this it might be more appropriate not to aggregate this kind of measures within the script else doing it within the UI which aligns the calculations to the selections and if you want to ignore some dimensionality in your calculation you could use the TOTAL &amp;lt;optional dimensions&amp;gt; statement.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2024 14:18:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Table-join-and-group-by-problem/m-p/2498611#M1226315</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2024-12-18T14:18:27Z</dc:date>
    </item>
  </channel>
</rss>

