<?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: Creating a hierarchy from indented column in Power Query</title>
    <link>https://community.fabric.microsoft.com/t5/Power-Query/Creating-a-hierarchy-from-indented-column/m-p/933165#M32142</link>
    <description>&lt;P&gt;Apologies &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="81408" data-lia-user-login="Mariusz" class="lia-mention lia-mention-user"&gt;Mariusz&lt;/a&gt;&amp;nbsp;, perhaps my example problem was too generic. I have updated my question to reflect the true scenario which i have where I believe your specific solution might not work.&lt;/P&gt;</description>
    <pubDate>Fri, 14 Feb 2020 11:55:08 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-02-14T11:55:08Z</dc:date>
    <item>
      <title>Creating a hierarchy from indented column</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Creating-a-hierarchy-from-indented-column/m-p/933027#M32137</link>
      <description>&lt;P&gt;I have the following table:&amp;nbsp;&lt;BR /&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It has a column that contains levels of indentation signifying a hierarchical relationship. I'd like to ask how this could be unwrapped into the following table please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Perhaps this should be sorted out with the help of Python script? All help and tips are appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2020 11:56:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Creating-a-hierarchy-from-indented-column/m-p/933027#M32137</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-14T11:56:14Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a hierarchy from indented column</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Creating-a-hierarchy-from-indented-column/m-p/933144#M32141</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use power query to transform.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please see the attached file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;Best Regards,&lt;BR /&gt;Mariusz&lt;BR /&gt;&lt;BR /&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;I&gt;Accepting it as the solution&lt;/I&gt;&lt;/STRONG&gt;.&lt;BR /&gt;&lt;BR /&gt;Please feel free to connect with me.&lt;BR /&gt;&lt;A href="https://www.linkedin.com/in/mariusz-repczynski-065a7362/" target="_blank"&gt; LinkedIn &lt;/A&gt;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2020 11:39:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Creating-a-hierarchy-from-indented-column/m-p/933144#M32141</guid>
      <dc:creator>Mariusz</dc:creator>
      <dc:date>2020-02-14T11:39:02Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a hierarchy from indented column</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Creating-a-hierarchy-from-indented-column/m-p/933165#M32142</link>
      <description>&lt;P&gt;Apologies &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="81408" data-lia-user-login="Mariusz" class="lia-mention lia-mention-user"&gt;Mariusz&lt;/a&gt;&amp;nbsp;, perhaps my example problem was too generic. I have updated my question to reflect the true scenario which i have where I believe your specific solution might not work.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2020 11:55:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Creating-a-hierarchy-from-indented-column/m-p/933165#M32142</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-14T11:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a hierarchy from indented column</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Creating-a-hierarchy-from-indented-column/m-p/933381#M32147</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcgQCpVidaCUFJyCAsBScDUEAynE0AgEYxxgEIBxnICBaQywA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Block = _t]),
    #"Added Index" = Table.AddIndexColumn(Source, "Index", 0, 1),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Level", each "Block Level " &amp;amp; Number.ToText( List.Count( List.Accumulate( Text.ToList( [Block] ), {" "}, ( s,a ) =&amp;gt; if a = List.Last(s) then s &amp;amp; {a} else s ) ) - 1 ) ),
    #"Trimmed Text" = Table.TransformColumns(#"Added Custom",{{"Block", Text.Trim, type text}}),
    #"Pivoted Column" = Table.Pivot(#"Trimmed Text", List.Distinct(#"Trimmed Text"[Level]), "Level", "Block"),
    #"Filled Down" = Table.FillDown(#"Pivoted Column",{"Block Level 0", "Block Level 1"}),
    #"Filtered Rows" = Table.SelectRows(#"Filled Down", each ([Block Level 2] &amp;lt;&amp;gt; null))
in
    #"Filtered Rows"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;Best Regards,&lt;BR /&gt;Mariusz&lt;BR /&gt;&lt;BR /&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;I&gt;Accepting it as the solution&lt;/I&gt;&lt;/STRONG&gt;.&lt;BR /&gt;&lt;BR /&gt;Please feel free to connect with me.&lt;BR /&gt;&lt;A href="https://www.linkedin.com/in/mariusz-repczynski-065a7362/" target="_blank"&gt; LinkedIn &lt;/A&gt;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2020 14:35:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Creating-a-hierarchy-from-indented-column/m-p/933381#M32147</guid>
      <dc:creator>Mariusz</dc:creator>
      <dc:date>2020-02-14T14:35:14Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a hierarchy from indented column</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Creating-a-hierarchy-from-indented-column/m-p/933453#M32153</link>
      <description>&lt;P&gt;Thank you very much for your help so far&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="81408" data-lia-user-login="Mariusz" class="lia-mention lia-mention-user"&gt;Mariusz&lt;/a&gt;! Your solution is very close however I can't seem to sort out the final format which currently is this:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I think it may be due to different indentation levels between your source data and mine?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2020 10:10:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Creating-a-hierarchy-from-indented-column/m-p/933453#M32153</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-20T10:10:45Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a hierarchy from indented column</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Creating-a-hierarchy-from-indented-column/m-p/933590#M32159</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="81408" data-lia-user-login="Mariusz" class="lia-mention lia-mention-user"&gt;Mariusz&lt;/a&gt;'s solution helped me to start digging into M functions.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I'll replace&amp;nbsp;&lt;SPAN&gt;#"Added Custom"&lt;/SPAN&gt; step with the next one, as you have to calculate level by number of leading spaces.&lt;/P&gt;&lt;P&gt;Is just my first try into M functions, hope this will help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;#"Added Custom" = Table.AddColumn(#"Added Index", "Level"&lt;BR /&gt;, each "Block Level " &amp;amp; Number.ToText(Text.Length([Block])-Text.Length(Text.TrimStart([Block])))),&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2020 17:22:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Creating-a-hierarchy-from-indented-column/m-p/933590#M32159</guid>
      <dc:creator>Miralon</dc:creator>
      <dc:date>2020-02-14T17:22:43Z</dc:date>
    </item>
  </channel>
</rss>

