<?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: Multiple Hierarchy Levels with Parents Including Children Values in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Multiple-Hierarchy-Levels-with-Parents-Including-Children-Values/m-p/1708749#M54400</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/5930"&gt;@jwjackso&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for your reply, I applied this HierarchyBelongsTo function, and its partly the solution I guess, because it helps me sum up the ancestors and those below them, but&amp;nbsp; something needs to be added to it and I have no idea what. The problem is that the hierarchy isn't fixed, you could have a sector that's a parent to base department, and the projects could be linked directly to a sector, or to a general department. What I'm getting with this solution is a sector on each level of department types, but it should stay the same type. Here's the actual data set attached for your reference, pardon the names of the departments as they are in Arabic, but they are not necessary.&lt;/P&gt;&lt;P&gt;The confusing part lies in the levels of ancestry.&lt;/P&gt;&lt;P&gt;Thanks so much for your time.&lt;/P&gt;&lt;P&gt;This is the code I used for Departments&lt;/P&gt;&lt;P&gt;Departments:&lt;BR /&gt;LOAD&lt;BR /&gt;DepartmentID,&lt;BR /&gt;Department,&lt;BR /&gt;DepartmentTypeID,&lt;BR /&gt;[Department Type],&lt;BR /&gt;ParentDepartmentID&lt;BR /&gt;FROM [Departments.qvd]&lt;BR /&gt;(qvd);&lt;/P&gt;&lt;P&gt;DepartmentBelongsTo:&lt;BR /&gt;HierarchyBelongsTo(DepartmentID,ParentDepartmentID,[Department],AncestorID,AncestorName,DepthDiff)&lt;BR /&gt;Load&lt;BR /&gt;DepartmentID,&lt;BR /&gt;Department,&lt;BR /&gt;ParentDepartmentID,&lt;BR /&gt;DepartmentTypeID,&lt;BR /&gt;[Department Type]&lt;BR /&gt;Resident Departments;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 06 Jun 2020 18:00:45 GMT</pubDate>
    <dc:creator>bashar_f</dc:creator>
    <dc:date>2020-06-06T18:00:45Z</dc:date>
    <item>
      <title>Multiple Hierarchy Levels with Parents Including Children Values</title>
      <link>https://community.qlik.com/t5/App-Development/Multiple-Hierarchy-Levels-with-Parents-Including-Children-Values/m-p/1708588#M54370</link>
      <description>&lt;P&gt;Hi, been pulling my hair over this for a week now, please help &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I have two tables, &lt;STRONG&gt;Departments&lt;/STRONG&gt; and &lt;STRONG&gt;Projects.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Projects&lt;/STRONG&gt; looks like this&lt;/P&gt;&lt;TABLE border="1" width="44.42567338553386%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;Project ID&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;Department ID&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;001&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;240&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;002&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;150&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="24px"&gt;003&lt;/TD&gt;&lt;TD height="24px"&gt;550&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;004&lt;/TD&gt;&lt;TD&gt;240&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;Departments&lt;/STRONG&gt; looks like this&lt;/P&gt;&lt;TABLE border="1" width="47.95296927383749%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="12.076401725200249%" height="24px"&gt;Department ID&lt;/TD&gt;&lt;TD width="2.233518176216883%" height="24px"&gt;Parent ID&lt;/TD&gt;&lt;TD width="13.944496105732748%"&gt;Department Type&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="12.076401725200249%" height="24px"&gt;240&lt;/TD&gt;&lt;TD width="2.233518176216883%" height="24px"&gt;150&lt;/TD&gt;&lt;TD width="13.944496105732748%"&gt;General Department&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="12.076401725200249%" height="24px"&gt;550&lt;/TD&gt;&lt;TD width="2.233518176216883%" height="24px"&gt;240&lt;/TD&gt;&lt;TD width="13.944496105732748%"&gt;Base Department&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="12.076401725200249%" height="24px"&gt;150&lt;/TD&gt;&lt;TD width="2.233518176216883%" height="24px"&gt;Null&lt;/TD&gt;&lt;TD width="13.944496105732748%"&gt;Sector&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;Some projects may be directly connected to a department through the department ID in the projects table, but they could also be connected to another department through the parent Id of its department in the department table. So when I count how many projects each department has, I must take into consideration the projects directly connected to it, and its children, and I need to do a &lt;STRONG&gt;drill down&lt;/STRONG&gt; process as well.&lt;/P&gt;&lt;P&gt;Using the above example it will look something like this.&lt;/P&gt;&lt;TABLE border="1" width="35.98765620478877%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;Department ID&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;# of Projects&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;240&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;550&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;150&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I'm going to drill down through &lt;STRONG&gt;Department Type,&amp;nbsp;&lt;/STRONG&gt;it would be Sectors&amp;gt;General Departments&amp;gt;Base Departments, and the number of projects for each should be the same as in the measure table above.&lt;/P&gt;&lt;P&gt;I've tried using the hierarchy function, but because projects are directly connected to departments on different levels, you'd get general departments in the base departments levels, and sectors in the general departments level and so on.&lt;/P&gt;&lt;P&gt;I've attached an excel with the tables above. I'd really appreciate some help on this.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 02:13:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Multiple-Hierarchy-Levels-with-Parents-Including-Children-Values/m-p/1708588#M54370</guid>
      <dc:creator>bashar_f</dc:creator>
      <dc:date>2024-11-16T02:13:28Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Hierarchy Levels with Parents Including Children Values</title>
      <link>https://community.qlik.com/t5/App-Development/Multiple-Hierarchy-Levels-with-Parents-Including-Children-Values/m-p/1708600#M54371</link>
      <description>&lt;P&gt;To get the count of project by department, you would use the&amp;nbsp;&lt;A href="https://help.qlik.com/en-US/qlikview/April2020/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptPrefixes/HierarchyBelongsTo.htm" target="_self"&gt;HierarchyBelongsTo&lt;/A&gt;&amp;nbsp; function.&amp;nbsp; using the data below:&lt;/P&gt;&lt;P&gt;Projects:&lt;BR /&gt;Load * Inline [&lt;BR /&gt;DepartmentID,ProjectID&lt;BR /&gt;240,'001'&lt;BR /&gt;150,'002'&lt;BR /&gt;550,'003'&lt;BR /&gt;240,'005'&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;Departments:&lt;BR /&gt;Load * Inline [&lt;BR /&gt;DepartmentID,ParentID,DepartmentType&lt;BR /&gt;240,150,'General Department'&lt;BR /&gt;550,240,'Base Department'&lt;BR /&gt;150,,'Sector'&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;DepartmentBelongsToHierarchy:&lt;BR /&gt;HierarchyBelongsTo(DepartmentID,ParentID,DepartmentType,AncestorID,AncestorName,DepthDiff)&lt;BR /&gt;Load DepartmentID,&lt;BR /&gt;ParentID,&lt;BR /&gt;DepartmentType&lt;BR /&gt;Resident Departments;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HierarchyBelongsTo.PNG" style="width: 676px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/35036i360B4ED8A5764C74/image-size/large?v=v2&amp;amp;px=999" role="button" title="HierarchyBelongsTo.PNG" alt="HierarchyBelongsTo.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;You would use the&amp;nbsp;&lt;A href="https://help.qlik.com/en-US/sense/April2020/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptPrefixes/Hierarchy.htm" target="_self"&gt;Hierarchy&lt;/A&gt;&amp;nbsp; function to create a drill down pivot table.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2020 15:59:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Multiple-Hierarchy-Levels-with-Parents-Including-Children-Values/m-p/1708600#M54371</guid>
      <dc:creator>jwjackso</dc:creator>
      <dc:date>2020-06-05T15:59:55Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Hierarchy Levels with Parents Including Children Values</title>
      <link>https://community.qlik.com/t5/App-Development/Multiple-Hierarchy-Levels-with-Parents-Including-Children-Values/m-p/1708617#M54374</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/44401"&gt;@bashar_f&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another approach, a long but fun one.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;For the hair! It'll grow out, don't worry &lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;
Departments:

Hierarchy([Department ID], [Parent ID],TmpID)

LOAD [Department ID] as TmpID,* INLINE [
    Department ID, Parent ID, Department Type
    240, 150, General Department
    550, 240, Base Department
    150, Null, Sector
]
;

CrossTmp:
noconcatenate
load TmpID as I,* resident Departments;

drop table Departments;
drop fields TmpID,[Department Type],[Parent ID] ,[Department ID];

Crosstable:
CrossTable(Tmp1, Tmp2)
load * resident CrossTmp;

drop table CrossTmp;
drop field Tmp1;

 join 


LOAD Department_ID as I,* INLINE [
    Project ID, Department_ID
    001, 240
    002, 150
    003, 550
    004, 240
];


output:
noconcatenate

load  Tmp2 as [Department ID],count([Project ID]) as NbrProject resident Crosstable group by Tmp2;

drop table Crosstable;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 753px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/35042iF75238508BEAD8B3/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2020 17:04:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Multiple-Hierarchy-Levels-with-Parents-Including-Children-Values/m-p/1708617#M54374</guid>
      <dc:creator>Taoufiq_Zarra</dc:creator>
      <dc:date>2020-06-05T17:04:44Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Hierarchy Levels with Parents Including Children Values</title>
      <link>https://community.qlik.com/t5/App-Development/Multiple-Hierarchy-Levels-with-Parents-Including-Children-Values/m-p/1708749#M54400</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/5930"&gt;@jwjackso&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for your reply, I applied this HierarchyBelongsTo function, and its partly the solution I guess, because it helps me sum up the ancestors and those below them, but&amp;nbsp; something needs to be added to it and I have no idea what. The problem is that the hierarchy isn't fixed, you could have a sector that's a parent to base department, and the projects could be linked directly to a sector, or to a general department. What I'm getting with this solution is a sector on each level of department types, but it should stay the same type. Here's the actual data set attached for your reference, pardon the names of the departments as they are in Arabic, but they are not necessary.&lt;/P&gt;&lt;P&gt;The confusing part lies in the levels of ancestry.&lt;/P&gt;&lt;P&gt;Thanks so much for your time.&lt;/P&gt;&lt;P&gt;This is the code I used for Departments&lt;/P&gt;&lt;P&gt;Departments:&lt;BR /&gt;LOAD&lt;BR /&gt;DepartmentID,&lt;BR /&gt;Department,&lt;BR /&gt;DepartmentTypeID,&lt;BR /&gt;[Department Type],&lt;BR /&gt;ParentDepartmentID&lt;BR /&gt;FROM [Departments.qvd]&lt;BR /&gt;(qvd);&lt;/P&gt;&lt;P&gt;DepartmentBelongsTo:&lt;BR /&gt;HierarchyBelongsTo(DepartmentID,ParentDepartmentID,[Department],AncestorID,AncestorName,DepthDiff)&lt;BR /&gt;Load&lt;BR /&gt;DepartmentID,&lt;BR /&gt;Department,&lt;BR /&gt;ParentDepartmentID,&lt;BR /&gt;DepartmentTypeID,&lt;BR /&gt;[Department Type]&lt;BR /&gt;Resident Departments;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Jun 2020 18:00:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Multiple-Hierarchy-Levels-with-Parents-Including-Children-Values/m-p/1708749#M54400</guid>
      <dc:creator>bashar_f</dc:creator>
      <dc:date>2020-06-06T18:00:45Z</dc:date>
    </item>
  </channel>
</rss>

