<?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: How to compare two dimensions with aggr function in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/How-to-compare-two-dimensions-with-aggr-function/m-p/1181156#M21829</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sunny,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It works for the sample database, but not for my production one. But, I switched the Count and If statement, and now it works for my database as well:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Sum(Aggr(If(RoomType2_ID = RoomType_ID, &lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Count(&lt;/STRONG&gt;Appointment_ID)), RoomType2_ID, RoomType_ID, Appointment_ID))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;So thanks a lot!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 14 Sep 2016 11:26:47 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2016-09-14T11:26:47Z</dc:date>
    <item>
      <title>How to compare two dimensions with aggr function</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-compare-two-dimensions-with-aggr-function/m-p/1181148#M21821</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need some help..&lt;/P&gt;&lt;P&gt;I’ve got an database, where appointments of several types are made on multiple locations.&lt;/P&gt;&lt;P&gt;Each appointment type can require different type of rooms (even multiple rooms)&lt;/P&gt;&lt;P&gt;Each location has several rooms of each type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So kind of like this (oversimplified):&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;AppointmentsTable:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;-AppID&lt;/P&gt;&lt;P&gt;-AppTypeID&lt;/P&gt;&lt;P&gt;-LocationID&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;RoomType:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;-RoomTypeID&lt;/P&gt;&lt;P&gt;-AppTypeID&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Location:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;-LocationID&lt;/P&gt;&lt;P&gt;-RoomTypeID&lt;/P&gt;&lt;P&gt;-CapacityOfRoomType&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now: If I load this in QV, I get a circular reference of course. So, I’ve renamed the ID of RoomType to RoomTypeID2 – which worked obviously.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But the problem is I can’t get the query right where I want to show the used Rooms vs the capacity.&lt;/P&gt;&lt;P&gt;I want to show:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RoomTypeID – Count(Appointments) – Count(Capacity)&lt;/P&gt;&lt;P&gt;A1 – 45 – 100&lt;/P&gt;&lt;P&gt;A2 – 50 – 102&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And now I don’t know to solve it. Any help?&lt;/P&gt;&lt;P&gt;I’ve tried a aggr function like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SUM(aggr(SUM([CapacityOfRoomType]),[RoomType Id], [RoomType2Id])). But it doesn’t work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I get:&lt;/P&gt;&lt;P&gt;RoomTypeID2 – Count(Appointments) – Count(Capacity)&lt;/P&gt;&lt;P&gt;A1 – 45 – 202&lt;/P&gt;&lt;P&gt;A2 – 50 – 202&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I include RoomTypeID then it shows all the correct values, So I should be close…&lt;/P&gt;&lt;P&gt;RoomType2ID – RoomTypeID - Count(Appointments) – Count(Capacity)&lt;/P&gt;&lt;P&gt;A1 – A1 – 45 – 100&lt;/P&gt;&lt;P&gt;A1 – A2 – 0 – 102&lt;/P&gt;&lt;P&gt;A2 – A1 – 50 – 100&lt;/P&gt;&lt;P&gt;A2 – A2 – 0 – 102&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried something like:&lt;/P&gt;&lt;P&gt;SUM(&lt;STRONG&gt;${&amp;lt;[RoomType2Id]]=[RoomType Id]&amp;gt;}&lt;/STRONG&gt;aggr(SUM(&lt;STRONG&gt;${&amp;lt;[RoomType2 Id]]=[RoomType Id]&amp;gt;}&lt;/STRONG&gt;[CapacityOfRoomType]),[RoomType Id], [RoomType2Id])). But it doesn’t work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope someone can help me by:&lt;/P&gt;&lt;OL style="list-style-type: lower-alpha;"&gt;&lt;LI&gt;a) Solving the circular reference by adjusting my data-model&lt;/LI&gt;&lt;LI&gt;b) Correct the function or replace it somehow.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Sep 2016 11:31:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-compare-two-dimensions-with-aggr-function/m-p/1181148#M21821</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-09-12T11:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two dimensions with aggr function</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-compare-two-dimensions-with-aggr-function/m-p/1181149#M21822</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How about this for a quick fix&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;&lt;STRONG&gt;Sum(Aggr(Sum(&lt;SPAN style="color: #ff0000;"&gt;If(&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;[RoomType Id] = &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;[RoomType2Id], &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;[CapacityOfRoomType]&lt;SPAN style="color: #ff0000;"&gt;)&lt;/SPAN&gt;),[RoomType Id], [RoomType2Id]))&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For a longer term fix may be create a better data model. It would be difficult to propose anything without looking at what you have today. Would you be able to share a sample?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Sep 2016 15:45:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-compare-two-dimensions-with-aggr-function/m-p/1181149#M21822</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2016-09-12T15:45:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two dimensions with aggr function</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-compare-two-dimensions-with-aggr-function/m-p/1181150#M21823</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sunny, Thanks, but it doesn't work. I've included a sample, maybe you can have a look ? Thanks a lot.&lt;/P&gt;&lt;P&gt;And yes, I'm eager to have the longer term fix &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Sep 2016 19:23:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-compare-two-dimensions-with-aggr-function/m-p/1181150#M21823</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-09-12T19:23:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two dimensions with aggr function</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-compare-two-dimensions-with-aggr-function/m-p/1181151#M21824</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How about this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Count(Aggr(If(RoomType_ID = RoomType2_ID, NrOfRooms),RoomType_ID, RoomType2_ID, NrOfRooms))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Capture.PNG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/137206_Capture.PNG" style="height: 149px; width: 620px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Sep 2016 00:01:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-compare-two-dimensions-with-aggr-function/m-p/1181151#M21824</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2016-09-13T00:01:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two dimensions with aggr function</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-compare-two-dimensions-with-aggr-function/m-p/1181152#M21825</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks allright, but it isn't unfortunately. If you add more rooms, you see that it doesn't work.&lt;/P&gt;&lt;P&gt;And I made a slight error in using Count instead of Sum.&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Capture.PNG" class="jive-image image-1" height="219" src="https://community.qlik.com/legacyfs/online/137237_Capture.PNG" style="height: 219px; width: 789.419px;" width="789" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See attached qvf.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;----&lt;/P&gt;&lt;P&gt;LocationRooms:&lt;/P&gt;&lt;P&gt;LOAD * Inline [Location_ID, RoomType_ID, NrOfRooms&lt;/P&gt;&lt;P&gt;&amp;nbsp; L1, R1, 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; L1, R2, 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; L2, R1, 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; L3, R1, 5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; L3, R2, 10&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Sep 2016 07:10:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-compare-two-dimensions-with-aggr-function/m-p/1181152#M21825</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-09-13T07:10:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two dimensions with aggr function</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-compare-two-dimensions-with-aggr-function/m-p/1181153#M21826</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The fact you get a circular reférence is not a problem.&lt;/P&gt;&lt;P&gt;have a look here for further info about circular reference&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.qlik.com/blogs/qlikviewdesignblog/2013/06/25/circular-references"&gt;https://community.qlik.com/blogs/qlikviewdesignblog/2013/06/25/circular-references&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So first i would try with a circular reference&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another way could be to join (leftjoin) the appointement table and the location table &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Sep 2016 07:48:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-compare-two-dimensions-with-aggr-function/m-p/1181153#M21826</guid>
      <dc:creator>brunobertels</dc:creator>
      <dc:date>2016-09-13T07:48:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two dimensions with aggr function</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-compare-two-dimensions-with-aggr-function/m-p/1181154#M21827</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For this sample file, the circular reference is indeed not the problem. Well spotted! But for my actual database, with over 10 tables, it is a problem. So I have to find a way to correct the circular reference, somehow as stated in the excellent example you posted (thanks!).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So indeed I need two keys: RoomType_ID and RoomType2_ID. Now I have to find the correct function to get both results in one table..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Sep 2016 12:50:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-compare-two-dimensions-with-aggr-function/m-p/1181154#M21827</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-09-13T12:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two dimensions with aggr function</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-compare-two-dimensions-with-aggr-function/m-p/1181155#M21828</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How about this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dimension&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;RoomType_ID&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Expressions&lt;/P&gt;&lt;P&gt;1) &lt;STRONG&gt;Sum(Aggr(Count(If(RoomType2_ID = RoomType_ID, Appointment_ID)), RoomType2_ID, RoomType_ID, Appointment_ID))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;2)&lt;STRONG&gt; Sum(NrOfRooms)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Capture.PNG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/137364_Capture.PNG" style="height: 264px; width: 620px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Sep 2016 02:10:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-compare-two-dimensions-with-aggr-function/m-p/1181155#M21828</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2016-09-14T02:10:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two dimensions with aggr function</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-compare-two-dimensions-with-aggr-function/m-p/1181156#M21829</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sunny,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It works for the sample database, but not for my production one. But, I switched the Count and If statement, and now it works for my database as well:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Sum(Aggr(If(RoomType2_ID = RoomType_ID, &lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Count(&lt;/STRONG&gt;Appointment_ID)), RoomType2_ID, RoomType_ID, Appointment_ID))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;So thanks a lot!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Sep 2016 11:26:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-compare-two-dimensions-with-aggr-function/m-p/1181156#M21829</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-09-14T11:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two dimensions with aggr function</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-compare-two-dimensions-with-aggr-function/m-p/1181157#M21830</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Awesome, I am glad I was able to put you in the right direction. Since you have been able to resolve the issue, I would suggest you to mark your response as correct and mark any helpful responses to close down this thread.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/docs/DOC-14806"&gt;Qlik Community Tip: Marking Replies as Correct or Helpful&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Sunny&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Sep 2016 01:06:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-compare-two-dimensions-with-aggr-function/m-p/1181157#M21830</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2016-09-15T01:06:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two dimensions with aggr function</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-compare-two-dimensions-with-aggr-function/m-p/1181158#M21831</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Sep 2016 08:45:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-compare-two-dimensions-with-aggr-function/m-p/1181158#M21831</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-09-16T08:45:56Z</dc:date>
    </item>
  </channel>
</rss>

