I have created the cost account like this
And this is how it looks in Power BI when data imported.
I am not sure how to develop a custom column in Power BI that can return levels and at the same time maintain relationship.
For instance
The column is indicating the child belongs to which parent. If is 762, then it is a “Level 1” of to 762 “Level 1”
Can someone please help with this use case?
Much Appreciated.
Since you are working in Power BI, you might want to try this approach that uses DAX.
This method could probably be better for two reasons:
So, try this instead:
Load your original table into Power BI. Then switch to the Data view to look at it.
Then click Column Tools > New Column and enter this into the formula box:
Hierarchy = PATH(Sheet1[acct_id],Sheet1[parent_acct_id])
Then click New Column again and enter this into the formula box:
Level = "Level " & CONVERT(LEN(Sheet1[Hierarchy])-LEN(SUBSTITUTE(Sheet1[Hierarchy],"|","")),STRING)
Then either hit the Enter key or click basically anywhere outside the formula box.
That should do it. You should see something like this:
You might find this helpful. I did.