I have 2 tables in Power BI (TableA and TableB). In tableA I have logins and I want to find the number of ID from tableB but in tableB the login is in a text. Ex:
tableA:
tableB:
Split TableB Logins by comma into new rows. Then Join the two tables.
let
//Read in Table B
Source = Excel.CurrentWorkbook(){[Name="TableB"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Logins", type text}, {"ID", Int64.Type}}),
//Split logins column by the comma into rows
//Then TRIM to get rid of leading/trailing spaces
#"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Changed Type", {{"Logins", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Logins"),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Logins", type text}}),
#"Trimmed Text" = Table.TransformColumns(#"Changed Type1",{{"Logins", Text.Trim, type text}}),
//Read in Table A and JOIN with B
Source2 = Excel.CurrentWorkbook(){[Name="TableA"]}[Content],
#"Changed Type2" = Table.TransformColumnTypes(Source2,{{"Logins", type text}}),
join=Table.NestedJoin(#"Changed Type2","Logins",#"Trimmed Text","Logins","Joined",JoinKind.LeftOuter),
//expand the joined table with ID only
#"Expanded Joined" = Table.ExpandTableColumn(join, "Joined", {"ID"}, {"ID"})
in
#"Expanded Joined"