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

Slicer to search for a specific string in a column - Power BI

我有两张桌子。

表 1

Category 
A
B
... 

表2

Companies | Indistries
1         | A,D,X
2         | Z,B,X
3         | N,D,R,B,Q

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

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

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

请从 link - HERE

下载示例报告文件

关注-

  1. 在 table your_table_name

    中创建了索引列
  2. 使用以下代码创建了一个新的 table 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_newtable-

的最终输出

  1. 回去汇报一下tableyour_table_nameslicer_new的关系.

  2. 从 table 创建切片器 slicer_new

  3. 从 table your_table_name[=49= 中为列 Indistries 添加 table 视觉对象]

  4. 现在切片器中的 select 值,现在一切都应该按预期工作了。