Forum Discussion
balaram51
Aug 03, 2019Copper Contributor
extract unique values matching a text string
I have two columns (A and B). Column A contains the dates and Column B contains the names of people who are required to attend the duty. Now based on this can i have names of people and just below th...
SergeiBaklan
Aug 06, 2019Diamond Contributor
If by Power Query some simple coding is required, not everything could be done from user interface. For such sample (I sorted names alphabetically)
the generated script is
let
Source = Excel.CurrentWorkbook()
{[Name="Table1"]}[Content],
NamesToLists = Table.TransformColumns(
Source,
{{"Persons required", Splitter.SplitTextByDelimiter(",")}}
),
ExpandNames = Table.ExpandListColumn(
NamesToLists,
"Persons required"
),
TrimmNames = Table.TransformColumns(
ExpandNames,
{{"Persons required", Text.Trim, type text}}
),
FormatAsDate = Table.TransformColumnTypes(
TrimmNames,
{{"Date", type date}}
),
GroupNames = Table.Group(
FormatAsDate,
{"Persons required"},
{{"Count", each _, type table [Date=date, Persons required=text]}}
),
AddCustom = Table.AddColumn(
GroupNames,
"Custom", each [Count][Date]
),
SortByNames = Table.Sort(
AddCustom,
{{"Persons required", Order.Ascending}}
),
CreateTable = Table.FromColumns(
SortByNames[Custom],
SortByNames[Persons required]
)
in
CreateTable
You may check step by step in the attached file.
nabilmourad
Aug 09, 2019MVP
Hi
I am missing the second step in the applied steps (NameToList) I see the M code but how did you do it from the interface of the Query Editor?
- SergeiBaklanAug 09, 2019Diamond Contributor
Hi Nabil,
There is no such exact action in user interface. You may select column, from right click menu select Transform with any function, e.g. Trim, and after that in formula bar change Text.Trim on any other suitable function, in our case Splitter.SplitTextByDelimiter(",")