0

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

1 Answer 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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.