Forum Discussion

suojis's avatar
suojis
New Member
5 years ago

Devops flatten workitems hierarchy

Hi gurus,

 

I have following devops odata script:

            $select=WorkItemId
            &$expand=Links($select=TargetWorkItemId,LinkTypeName)
 
This returns table into power bi:
WorkItemId       TargetWorkItemId      LinkTypeName
1                        2                                 Child
1                        3                                 Child
2                        4                                 Child
3                        1                                 Related
 
 
 
Which is best way to create following table
 
WorkItemId       TargetWorkID          LinkTypeName          Level
1                        2                                 Child                        1
1                        3                                 Child                        1
1                        4                                 Child                        2
2                        4                                 Child                        1
3                        1                                 Related                    1
3                        2                                 Child                        2
3                        4                                 Child                        3
 
So I need flatten recursive table for all master items. There are loops in structure, so level depth must define in table creation script or recursive loop must stop when master item or structure item comes second time in loop.
Any hints?

5 Replies

    • suojis's avatar
      suojis
      New Member
      Sorry about text data. Here is my data in tables.
      Original
      WorkItemId TargetWorkItemIdLinkTypeName
      12Child
      13Child
      24Child
      31Related

      Goal
      WorkItemIdTargetWorkIDLinkTypeNameLevel
      12Child1
      13Child1
      14Child2
      24Child1
      31Related1
      32Child2
      34Child3
       
      So row 3 shows workitemid 1 second hierarchy level. If I want to show all hierarchy levels (all parts and subparts), then I just filter column workitemid. Thanks for reply and hope this helps. edhans 
      • edhans's avatar
        edhans
        Community Champion

        Hi suojis - if someone else jumps in that is great. I am slammed and I need to take a step back and look at this, so I haven't abandoned it, but this is not a quick fix that I can see yet. I will look at more earnestly tonight or tomorrow when I am past my deadline today with work. 👍