Forum Discussion
Slicer to filter multiple columns
- 4 years ago
Hi Woodpecker
If you create a slicer table from the data table removing all columns except the Lead column, then duplicate the Lead column and use split by delimiter 'column to rows' on the Lead column. You will get a table like below that can be linked to your data table and used to filter by all the names.
Also using the Text.Trim function on the Lead column on the slicer table will remove any blank spaces around the names. See M-code below
Slicer Table
Joe Bloggs Joe Bloggs Joe Bloggs Joe Bloggs, John Doe, Jane Air John Doe Joe Bloggs, John Doe, Jane Air Jane Air Joe Bloggs, John Doe, Jane Air John Doe John Doe, Jane Air Jane Air John Doe, Jane Air John Doe John Doe Joe Bloggs Joe Bloggs, John Doe John Doe Joe Bloggs, John Doe Jane Air Jane Air, Joe Bloggs Joe Bloggs Jane Air, Joe Bloggs Jane Air Jane Air, John Doe John Doe Jane Air, John Doe The M-code for slicer table (Replace 'SampleData' with your data table name)
let Source = SampleData, #"Removed Other Columns" = Table.SelectColumns(Source,{"Lead"}), #"Removed Duplicates" = Table.Distinct(#"Removed Other Columns"), #"Duplicated Column" = Table.DuplicateColumn(#"Removed Duplicates", "Lead", "Lead link"), #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Duplicated Column", {{"Lead", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Lead"), #"Changed Type" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Lead", type text}}), #"Trimmed Text" = Table.TransformColumns(#"Changed Type",{{"Lead", Text.Trim, type text}}) in #"Trimmed Text"Hope this helps
Hi Woodpecker
If you create a slicer table from the data table removing all columns except the Lead column, then duplicate the Lead column and use split by delimiter 'column to rows' on the Lead column. You will get a table like below that can be linked to your data table and used to filter by all the names.
Also using the Text.Trim function on the Lead column on the slicer table will remove any blank spaces around the names. See M-code below
Slicer Table
| Joe Bloggs | Joe Bloggs |
| Joe Bloggs | Joe Bloggs, John Doe, Jane Air |
| John Doe | Joe Bloggs, John Doe, Jane Air |
| Jane Air | Joe Bloggs, John Doe, Jane Air |
| John Doe | John Doe, Jane Air |
| Jane Air | John Doe, Jane Air |
| John Doe | John Doe |
| Joe Bloggs | Joe Bloggs, John Doe |
| John Doe | Joe Bloggs, John Doe |
| Jane Air | Jane Air, Joe Bloggs |
| Joe Bloggs | Jane Air, Joe Bloggs |
| Jane Air | Jane Air, John Doe |
| John Doe | Jane Air, John Doe |
The M-code for slicer table (Replace 'SampleData' with your data table name)
let
Source = SampleData,
#"Removed Other Columns" = Table.SelectColumns(Source,{"Lead"}),
#"Removed Duplicates" = Table.Distinct(#"Removed Other Columns"),
#"Duplicated Column" = Table.DuplicateColumn(#"Removed Duplicates", "Lead", "Lead link"),
#"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Duplicated Column", {{"Lead", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Lead"),
#"Changed Type" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Lead", type text}}),
#"Trimmed Text" = Table.TransformColumns(#"Changed Type",{{"Lead", Text.Trim, type text}})
in
#"Trimmed Text"
Hope this helps