'How find a string in a text from another table using power bi

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:

enter image description here

tableB:

enter image description here



Solution 1:[1]

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"

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ron Rosenfeld