<?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: Define hierarchy by Id in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Define-hierarchy-by-Id/m-p/976334#M333725</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can try with Hierarchy function in scripting&lt;/P&gt;&lt;P&gt;or use below expression:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Trim(Replace(ID,subfield(ID,'.',-1),'')) as ParentID&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want put the null if there in no parent then modified the expression:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;IF( ID = &lt;/STRONG&gt;&lt;STRONG style="font-size: 13.3333px;"&gt;Trim(Replace(ID,subfield(ID,'.',-1),'')) , Null() , &lt;STRONG style="font-size: 13.3333px;"&gt;Trim(Replace(ID,subfield(ID,'.',-1),'')) ) AS ParentID&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 28 Oct 2015 14:23:29 GMT</pubDate>
    <dc:creator />
    <dc:date>2015-10-28T14:23:29Z</dc:date>
    <item>
      <title>Define hierarchy by Id</title>
      <link>https://community.qlik.com/t5/QlikView/Define-hierarchy-by-Id/m-p/976333#M333724</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi to eveyone!&lt;/P&gt;&lt;P&gt;Please help! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a table:&lt;/P&gt;&lt;P&gt;ID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;1.1&lt;/P&gt;&lt;P&gt;1.1.1&lt;/P&gt;&lt;P&gt;1.1.2&lt;/P&gt;&lt;P&gt;1.1.2.1&lt;/P&gt;&lt;P&gt;1.1.2.2&lt;/P&gt;&lt;P&gt;1.1.2.2.1&lt;/P&gt;&lt;P&gt;1.2&lt;/P&gt;&lt;P&gt;1.2.1&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I define that "1" is a parent for "1.1", "1.1" is a parent for "1.1.1" and "1.1.2". There is 4 levels of hierarchy.&lt;/P&gt;&lt;P&gt;I tried to use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if(len(ID)&amp;gt;=len(previous(ID)),alt(peek(Parent),previous(ID))) as Parent&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but it works only partly, it compares only previous and current row. But it should take ID when it find the first short (in length) ID from the all previous rows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Oct 2015 03:58:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Define-hierarchy-by-Id/m-p/976333#M333724</guid>
      <dc:creator />
      <dc:date>2015-10-28T03:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: Define hierarchy by Id</title>
      <link>https://community.qlik.com/t5/QlikView/Define-hierarchy-by-Id/m-p/976334#M333725</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can try with Hierarchy function in scripting&lt;/P&gt;&lt;P&gt;or use below expression:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Trim(Replace(ID,subfield(ID,'.',-1),'')) as ParentID&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want put the null if there in no parent then modified the expression:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;IF( ID = &lt;/STRONG&gt;&lt;STRONG style="font-size: 13.3333px;"&gt;Trim(Replace(ID,subfield(ID,'.',-1),'')) , Null() , &lt;STRONG style="font-size: 13.3333px;"&gt;Trim(Replace(ID,subfield(ID,'.',-1),'')) ) AS ParentID&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Oct 2015 14:23:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Define-hierarchy-by-Id/m-p/976334#M333725</guid>
      <dc:creator />
      <dc:date>2015-10-28T14:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: Define hierarchy by Id</title>
      <link>https://community.qlik.com/t5/QlikView/Define-hierarchy-by-Id/m-p/976335#M333726</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But it also works partially.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;"1.1.6.1" - "..6." - wrong&lt;/P&gt;&lt;P&gt;"1.1.6.2" - "1.1.6" - ok&lt;/P&gt;&lt;P&gt;"1.1.6.6" -&amp;nbsp; "1.1.." - wrong&lt;/P&gt;&lt;P&gt;"1.1.7.1" - "..7." - wrong&lt;/P&gt;&lt;P&gt;"1.1.7.7" - "1.1.." - wrong&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, as you see, in some cases it do not work. It is strange, because logically it should work correctly. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Oct 2015 18:24:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Define-hierarchy-by-Id/m-p/976335#M333726</guid>
      <dc:creator />
      <dc:date>2015-10-28T18:24:08Z</dc:date>
    </item>
    <item>
      <title>Re: Define hierarchy by Id</title>
      <link>https://community.qlik.com/t5/QlikView/Define-hierarchy-by-Id/m-p/976336#M333727</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think I have found a solution:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;left(ID,index(ID,'.',-1)-1) as ParentID&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Oct 2015 18:36:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Define-hierarchy-by-Id/m-p/976336#M333727</guid>
      <dc:creator />
      <dc:date>2015-10-28T18:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: Define hierarchy by Id</title>
      <link>https://community.qlik.com/t5/QlikView/Define-hierarchy-by-Id/m-p/976337#M333728</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;to get different selection and analysis options using the different hierarchy levels of your ID field, you could try something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="QlikCommunity_Thread_189323_Pic1.JPG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/103404_QlikCommunity_Thread_189323_Pic1.JPG" style="height: auto; width: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="QlikCommunity_Thread_189323_Pic2.JPG" class="jive-image image-2" src="https://community.qlik.com/legacyfs/online/103405_QlikCommunity_Thread_189323_Pic2.JPG" style="height: auto; width: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="QlikCommunity_Thread_189323_Pic3.JPG" class="jive-image image-3" src="https://community.qlik.com/legacyfs/online/103406_QlikCommunity_Thread_189323_Pic3.JPG" style="height: auto; width: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="QlikCommunity_Thread_189323_Pic4.JPG" class="image-4 jive-image" src="https://community.qlik.com/legacyfs/online/103407_QlikCommunity_Thread_189323_Pic4.JPG" style="height: auto; width: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="QlikCommunity_Thread_189323_Pic5.JPG" class="image-5 jive-image" src="https://community.qlik.com/legacyfs/online/103408_QlikCommunity_Thread_189323_Pic5.JPG" style="height: auto; width: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="QlikCommunity_Thread_189323_Pic6.JPG" class="jive-image image-6" src="https://community.qlik.com/legacyfs/online/103409_QlikCommunity_Thread_189323_Pic6.JPG" style="height: auto; width: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14460759152824246" jivemacro_uid="_14460759152824246"&gt;
&lt;P&gt;tabIDs:&lt;/P&gt;
&lt;P&gt;LOAD Text(ID) as ID,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Text(Left(ID,Index(ID&amp;amp;'.','.',IterNo())-1)) as HierarchyID,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IterNo() as Level&lt;/P&gt;
&lt;P&gt;While IterNo()&amp;lt;=SubStringCount(ID,'.')+1;&lt;/P&gt;
&lt;P&gt;LOAD * Inline [&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ID&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.1.1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.1.2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.1.2.1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.1.2.2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.1.2.2.1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.2.1&lt;/P&gt;
&lt;P&gt;];&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;tabLevels:&lt;/P&gt;
&lt;P&gt;Generic LOAD&lt;/P&gt;
&lt;P&gt;&amp;nbsp; ID,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; 'Level'&amp;amp;Level&amp;amp;'ID',&lt;/P&gt;
&lt;P&gt;&amp;nbsp; HierarchyID&lt;/P&gt;
&lt;P&gt;Resident tabIDs;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;tabParents:&lt;/P&gt;
&lt;P&gt;Generic LOAD&lt;/P&gt;
&lt;P&gt;&amp;nbsp; ID,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; 'Parent'&amp;amp;(SubStringCount(ID,'.')+1-Level)&amp;amp;'ID',&lt;/P&gt;
&lt;P&gt;&amp;nbsp; HierarchyID&lt;/P&gt;
&lt;P&gt;Resident tabIDs&lt;/P&gt;
&lt;P&gt;Where Level&amp;lt;=SubStringCount(ID,'.');&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope this helps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marco&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Oct 2015 23:45:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Define-hierarchy-by-Id/m-p/976337#M333728</guid>
      <dc:creator>MarcoWedel</dc:creator>
      <dc:date>2015-10-28T23:45:41Z</dc:date>
    </item>
    <item>
      <title>Re: Define hierarchy by Id</title>
      <link>https://community.qlik.com/t5/QlikView/Define-hierarchy-by-Id/m-p/976338#M333729</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much, Marco!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2015 02:57:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Define-hierarchy-by-Id/m-p/976338#M333729</guid>
      <dc:creator />
      <dc:date>2015-10-29T02:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: Define hierarchy by Id</title>
      <link>https://community.qlik.com/t5/QlikView/Define-hierarchy-by-Id/m-p/976339#M333730</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You're welcome&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marco&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2015 23:23:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Define-hierarchy-by-Id/m-p/976339#M333730</guid>
      <dc:creator>MarcoWedel</dc:creator>
      <dc:date>2015-10-29T23:23:56Z</dc:date>
    </item>
  </channel>
</rss>

