Quantcast
Channel: All Developer posts
Viewing all articles
Browse latest Browse all 48312

Re: Is there a way to crate parent Child relationship on the same table and show results in a table?

$
0
0

Eric_Zhang wrote:

amithegde wrote:

Eric_Zhang wrote:

amithegde wrote:

Thanks @Eric_Zhang

 

apologies for being vague. By table I meant `table` visualization control. The idea is to be able to browse/see children of a selected item in a tabular format.

 

The answer you posted is very close. I am looking for a slight modification: If `1` selected on the slicer on the sample, table on the right should display all of the rows (Item ID 1 -6) as they are all children of 1. As of now it works for only one level, in the sense if 3 is selected on the slicer, it shows 3 and 5 which is level 1.

 

Thanks for the help.. Smiley Happy


It works for only one level because I've followed the description in your original post. To achieve the new requirement, you can just remove the filter.

Table = 
FILTER (
    CROSSJOIN (
        SELECTCOLUMNS (
            Table1,
            "Itemid", Table1[ItemId],
            "pathLen", PATHLENGTH ( PATH ( Table1[ItemId], Table1[ParentId] ) )
        ),
        SELECTCOLUMNS (
            Table1,
            "Itemid2", Table1[ItemId],
            "ParentID2", Table1[ParentId],
            "path2", PATH ( Table1[ItemId], Table1[ParentId] ),
            "pathLen2", PATHLENGTH ( PATH ( Table1[ItemId], Table1[ParentId] ) )
        )
    ),
    PATHCONTAINS ( [path2], [Itemid] )        //&& [pathLen2] - [pathLen]
        //<= 1
)

 

This works perfect, except that if any value other than `null` which is not in the list ItemId is provided for the first row's parent. Is that a limitation of the CrossJoin?


 

It is actually a limitation of PATH. By the way, why a not existed ItemID as ParentId, it doesn't make sense for me, in my opinion, the top level shouldn't have any ParentId, namely the ParentId should be null.

 


When parent Id can be from another table, while some of the parents can be from the current table, there can be parents which are not found on the current table as ItemId. For the simplified example above, I just mentioned `0` to represent some value which is not in the ItemId.

 

It's like this:

 

Table1:

 

Id | Title

 

100 | abc

200 | abcd

300 | abcde

 

Table 2:

 

Id | ParentId | Title

1 | 300 | xyz  --> parent from another table

2 | 1     | xyz1  --> parent from current table

3 | 2     |  xyz2 

4 | 100 | xyz3

 


Viewing all articles
Browse latest Browse all 48312

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>