March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
So I have a table with a column that lists multiple names in each row. Only one name in each row is relevant. I want to get rid of the other names, based on a list of names I have stored elsewhere.
So:
Names | Value |
Joe, Clara, Sharon | x |
Kelly, Clara, John, Barbara | y |
Jacob, Kelly | z |
I only care about Joe and Kelly, so what I would want to see is:
Names | Value |
Joe | x |
Kelly | y |
Kelly | z |
I don't know if I need to change the query or do a calculated column or something else. I tried splitting the columns and creating a new column but I've got a lot of data and a long list of names I want to pull from that names column. I'd rather not list out the several dozen names that should be checked for in each of the 4 newly created columns. Is there a relatively simple way to tackle this?
Solved! Go to Solution.
@Anonymous IDNumber is not correc,t you want [Value]
Agent =
VAR __NamesICareAbout = ALL(Agents[Name])
VAR __Text = SUBSTITUTE([Assigned To],",","|")
VAR __Count = PATHLENGTH(__Text)
VAR __Table =
FILTER(
ADDCOLUMNS(
GENERATESERIES(1,__Count,1),
"__Name",
PATHITEM(__Text,[Value])
),
[__Name] IN __NamesICareAbout
)
RETURN
CONCATENATEX(__Table,[__Name],";")
You are using the "index" created by GENERATESERIES to pull the correct path item out of the text path. GENERATESERIES creates a single column table with the column name "Value".
Hi,
You may download my PBI file from here.
Hope this helps.
Hi @Anonymous
If I understand it correctly, you can keep the data simple and clean, here is one way in M. Not sure if you will have Joe and Kelly in the same list, so use list, you can add more names if you care someone else other than Joe and Kelly
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8spP1VFwzkksStRRCM5ILMrPU9JRqlCK1YlW8k7NyamES3rlZ+TpKDglFiUBuUA1lWA1XonJ+Uk6CmClQMEqpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Names = _t, Value = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Names", type text}, {"Value", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "newName", each List.Select(Text.Split([Names],", "), each List.Contains({"Joe","Kelly"}, _))),
#"Expanded newName" = Table.ExpandListColumn(#"Added Custom", "newName")
in
#"Expanded newName"
@Anonymous One way:
Column =
VAR __NamesICareAbout = SELECTCOLUMNS('PeopeWhoMatter'[Names])
VAR __Text = SUBSTITUE([Names],", ","|")
VAR __Count = PATHLENGTH(__Text)
VAR __Table =
FILTER(
ADDCOLUMNS(
GENERATESERIES(1,__Count,1),
"__Name",PATHITEM(__Text,[Value])
),
[__Name] IN __NamesICareAbout
)
RETURN
CONCATENATEX(__Table,[__Name],", ")
@Greg_Deckler Soooo DAX is all I'm comfortable with, so I tried your solution. This is what I input:
@Anonymous IDNumber is not correc,t you want [Value]
Agent =
VAR __NamesICareAbout = ALL(Agents[Name])
VAR __Text = SUBSTITUTE([Assigned To],",","|")
VAR __Count = PATHLENGTH(__Text)
VAR __Table =
FILTER(
ADDCOLUMNS(
GENERATESERIES(1,__Count,1),
"__Name",
PATHITEM(__Text,[Value])
),
[__Name] IN __NamesICareAbout
)
RETURN
CONCATENATEX(__Table,[__Name],";")
You are using the "index" created by GENERATESERIES to pull the correct path item out of the text path. GENERATESERIES creates a single column table with the column name "Value".
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
114 | |
76 | |
57 | |
52 | |
44 |
User | Count |
---|---|
168 | |
116 | |
63 | |
57 | |
50 |