切片器以搜索列中的特定字符串-Power BI

时间:2020-10-23 12:38:52

标签: powerbi relationship powerbi-desktop

我有两个桌子。

表1

a['salary'] = df['example'].copy()

Table2

Category 
A
B
... 

我想要一个具有不同类别(A-Z)的切片器。单击A时,应根据“包含”行业A的公司对所有图表进行过滤。

长话短说:这就像是正常的关系,但与其找到相同的关系,不如说是“包含”。

谢谢您的帮助!非常感谢。

1 个答案:

答案 0 :(得分:0)

请从链接-HERE

中下载示例报告文件

关注-

  1. 在表您的表名

    中创建了索引列
  2. 使用以下代码创建新表 slicer_new -

let
    Source = your_table_name,
    #"Split Column by Delimiter" = Table.SplitColumn(Source, "Indistries", Splitter.SplitTextByDelimiter(", ", QuoteStyle.Csv), {"Indistries.1", "Indistries.2", "Indistries.3", "Indistries.4"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Indistries.1", type text}, {"Indistries.2", type text}, {"Indistries.3", type text}, {"Indistries.4", type text}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Index"}, "Attribute", "Value"),
    #"Removed Columns" = Table.RemoveColumns(#"Unpivoted Other Columns",{"Attribute"})
in
    #"Removed Columns"

以下是 slicer_new 表的最终输出-

enter image description here

  1. 返回报告并检查表您的表名 slicer_new 之间的关系。

  2. 从表 slicer_new

    创建切片器
  3. 为表您的表名

    中的列 Indistries 添加表视觉
  4. 现在在切片器中选择值,一切都应该按预期工作。