Forum Discussion

rdiazjimenez's avatar
rdiazjimenez
Frequent Visitor
6 years ago
Solved

Add index to hierarchy leves for later sorting

Hi, Using: Excel Power Query (Win64O365)   I'm trying to sort pivot table items based on their current position with a dynamically built hierarchy.   Currently using the code generously provid...
  • ImkeF's avatar
    ImkeF
    6 years ago

    Hi rdiazjimenez 

    Agree with dax  , don't understand the requirement from 2)

     

    Technically, you could limit the number of levels in the fnAllParents step by adding a limit on the Level in the List.Generate function:

     

    each Table.RowCount([Result]) > 0

     

    each Table.RowCount([Result]) > 0 and Level <= YourMaxLevel

  • rdiazjimenez's avatar
    rdiazjimenez
    6 years ago

    Thank you both ImkeF and dax ,

     

    I tried at that line, but missed that the one that I had to limit was [Level] and not Table.RowCount([Result])

     

    so Imke's solution was correct by adding the surrounding brackets.

     

    each Table.RowCount([Result]) > 0 and [Level] <= YourMaxLevel