I have a sample data as follows
I need to create a hierarchical slicer using the name field based on the parent id and id
我有一个示例数据,如下所示。我需要使用基于父id和id的名称字段创建一个分层切片器
id |
parent Id |
name |
1 |
null |
A |
2 |
null |
B |
3 |
1 |
a1 |
4 |
1 |
a2 |
5 |
3 |
a1-1 |
6 |
3 |
a1-2 |
7 |
4 |
a2-1 |
8 |
4 |
a2-2 |
9 |
2 |
b1 |
10 |
2 |
b2 |
11 |
9 |
b1-1 |
12 |
9 |
b1-2 |
13 |
10 |
b2-1 |
14 |
10 |
b2-2 |
I am expecting a slicer as follows:
我期待一台切片机,如下所示:
A*(top-level)*
A*(顶级)*
a1*(second-level)*
a1*(二级)*
a2 *(second-level)
a2*(二级)
B*(top-level)
B*(顶级)
b1*(second-level)
b1*(二级)
b2*(second-level)
b2*(二级)
I have tried using DAX PATH which does not work on direct query mode, I was able to create a column Level of hierarchy with values 0,1,2( Not in a very accurate way). But unsure and experimenting how to create the slicer using the level of hierarchy.
我尝试过使用DAX PATH,它不适用于直接查询模式,我能够创建一个值为0,1,2的列层次结构级别(不是以一种非常准确的方式)。但不确定并尝试如何使用层次结构级别创建切片器。
I would appreciate if someone can help me to achieve this. It would also be helpful if anyone can tell me how to establish a relationship between these parent and child ids and creating levels of hierarchy
如果有人能帮助我实现这一目标,我将不胜感激。如果有人能告诉我如何在这些父ID和子ID之间建立关系并创建层次结构级别,那也会很有帮助
Note: The data is in direct query mode hence some of the transformations are not possible( but welcoming answers in working with both import and direct query mode for my knowledge). THANKS IN Advance
注意:数据处于直接查询模式,因此有些转换是不可能的(但据我所知,在使用导入和直接查询模式时,欢迎回答)。提前感谢
更多回答
You have to build table before (with Level1, Level2, Level3... columns). 1. Preferable way to build this table is SQL, as far as recursion is NOT available in DAX. 2. if you have to build it on DAX level, please use parent-child hierarchies in DAX (you will need PATH
and PATHITEM
functions set).
您必须先构建表(具有Level1、Level2、Level3…列)。1.构建此表的首选方法是SQL,因为递归在DAX中不可用。2.如果你必须在DAX级别上构建它,请在DAX中使用父子层次结构(你需要设置PATH和PATHTITEM函数)。
优秀答案推荐
我是一名优秀的程序员,十分优秀!