title: How do I create a custom index column in PowerQuery?
body: <p>I have the following data in PowerQuery:</p>
  
  <pre><code>| ParentX | A |
  | ParentY | A |
  | ParentZ | A |
  | ParentY | B |
  | ParentZ | B |
  | ParentX | C |
  | ParentY | C |
  | ParentZ | C |
  </code></pre>
  
  <p>I want to add an index column that counts the number of parents for an element:</p>
  
  <pre><code>| ParentX | A | 3 |
  | ParentY | A | 2 |
  | ParentZ | A | 1 |
  | ParentY | B | 2 |
  | ParentZ | B | 1 |
  | ParentX | C | 3 |
  | ParentY | C | 2 |
  | ParentZ | C | 1 |
  </code></pre>
  
  <p>The end goal is to pivot based on this new column like this:</p>
  
  <pre><code>| Object | Root    | Parent 2 | Parent 3 |
  | A      | ParentZ | ParentY  | ParentX  |
  | B      | ParentZ | ParentY  |          |
  | C      | ParentZ | ParentY  | ParentX  |
  </code></pre>