Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Create a unique values list form 2 text strings in the same table

I have a list of Unique member IDs along with a list of names of the members as semicolon-delimited text strings, similar to the table below.

Each member ID is assigned to a unique Member no matter the order the ID shows.

I would like to be able to create a unique MemberID - Member table from the data source, how to do that?

 

MembersIDMembers
1;2;3;4;5;6;7;8AB;CD;EF;GH;IJ;KL;MN;OP 
4;8;9GH;OP;QR
3;6;1;2KL;EF;AB;CD

 

The result I am expecting:

 

MemberIDMember
1AB
2CD
3EF
4GH
5IJ
6KL
7MN
8OP
9QR

 

Thanks!

1 ACCEPTED SOLUTION
v-diye-msft
Community Support
Community Support

Hi @Anonymous 

 

It seems you've wrote the wrong string for EF and KL.  should be:

3;6;1;2 EF;KL;AB;CD

Based on this, kindly check the solution in power query:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("HYw5DoAwEMS+grZOA+EIcsV9k0Ab5f/fYEXrsSdGySmwlFTUNDgx0vUMI9PMsrLtHCfXjQ+ZJBOlxNGqpJsPPO8Prbb6o1hlDf8HSekD", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [MembersID = _t, Members = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"MembersID", type text}, {"Members", type text}}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "MembersID", Splitter.SplitTextByDelimiter(";", QuoteStyle.Csv), {"MembersID.1", "MembersID.2", "MembersID.3", "MembersID.4", "MembersID.5", "MembersID.6", "MembersID.7", "MembersID.8"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"MembersID.1", Int64.Type}, {"MembersID.2", Int64.Type}, {"MembersID.3", Int64.Type}, {"MembersID.4", Int64.Type}, {"MembersID.5", Int64.Type}, {"MembersID.6", Int64.Type}, {"MembersID.7", Int64.Type}, {"MembersID.8", Int64.Type}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type1", {"Members"}, "Attribute", "Value"),
    #"Split Column by Delimiter1" = Table.SplitColumn(#"Unpivoted Columns", "Members", Splitter.SplitTextByDelimiter(";", QuoteStyle.Csv), {"Members.1", "Members.2", "Members.3", "Members.4", "Members.5", "Members.6", "Members.7", "Members.8"}),
    #"Changed Type2" = Table.TransformColumnTypes(#"Split Column by Delimiter1",{{"Members.1", type text}, {"Members.2", type text}, {"Members.3", type text}, {"Members.4", type text}, {"Members.5", type text}, {"Members.6", type text}, {"Members.7", type text}, {"Members.8", type text}}),
    #"Unpivoted Columns1" = Table.UnpivotOtherColumns(#"Changed Type2", {"Attribute", "Value"}, "Attribute.1", "Value.1"),
    #"Filtered Rows" = Table.SelectRows(#"Unpivoted Columns1", each true),
    #"Split Column by Delimiter2" = Table.SplitColumn(#"Filtered Rows", "Attribute", Splitter.SplitTextByDelimiter(".", QuoteStyle.Csv), {"Attribute.1.1", "Attribute.2"}),
    #"Changed Type3" = Table.TransformColumnTypes(#"Split Column by Delimiter2",{{"Attribute.1.1", type text}, {"Attribute.2", Int64.Type}}),
    #"Split Column by Delimiter3" = Table.SplitColumn(#"Changed Type3", "Attribute.1", Splitter.SplitTextByDelimiter(".", QuoteStyle.Csv), {"Attribute.1.1.1", "Attribute.1.2"}),
    #"Changed Type4" = Table.TransformColumnTypes(#"Split Column by Delimiter3",{{"Attribute.1.1.1", type text}, {"Attribute.1.2", Int64.Type}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type4",{"Attribute.1.1", "Attribute.1.1.1"}),
    #"Added Custom" = Table.AddColumn(#"Removed Columns", "Custom", each if [Attribute.2] = [Attribute.1.2]
then [Value]
else null),
    #"Filtered Rows1" = Table.SelectRows(#"Added Custom", each ([Custom] <> null)),
    #"Removed Columns1" = Table.RemoveColumns(#"Filtered Rows1",{"Attribute.2", "Attribute.1.2", "Value"}),
    #"Removed Duplicates" = Table.Distinct(#"Removed Columns1")
in
    #"Removed Duplicates"

 

Pbix attached.

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

View solution in original post

4 REPLIES 4
v-diye-msft
Community Support
Community Support

Hi @Anonymous 

 

It seems you've wrote the wrong string for EF and KL.  should be:

3;6;1;2 EF;KL;AB;CD

Based on this, kindly check the solution in power query:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("HYw5DoAwEMS+grZOA+EIcsV9k0Ab5f/fYEXrsSdGySmwlFTUNDgx0vUMI9PMsrLtHCfXjQ+ZJBOlxNGqpJsPPO8Prbb6o1hlDf8HSekD", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [MembersID = _t, Members = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"MembersID", type text}, {"Members", type text}}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "MembersID", Splitter.SplitTextByDelimiter(";", QuoteStyle.Csv), {"MembersID.1", "MembersID.2", "MembersID.3", "MembersID.4", "MembersID.5", "MembersID.6", "MembersID.7", "MembersID.8"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"MembersID.1", Int64.Type}, {"MembersID.2", Int64.Type}, {"MembersID.3", Int64.Type}, {"MembersID.4", Int64.Type}, {"MembersID.5", Int64.Type}, {"MembersID.6", Int64.Type}, {"MembersID.7", Int64.Type}, {"MembersID.8", Int64.Type}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type1", {"Members"}, "Attribute", "Value"),
    #"Split Column by Delimiter1" = Table.SplitColumn(#"Unpivoted Columns", "Members", Splitter.SplitTextByDelimiter(";", QuoteStyle.Csv), {"Members.1", "Members.2", "Members.3", "Members.4", "Members.5", "Members.6", "Members.7", "Members.8"}),
    #"Changed Type2" = Table.TransformColumnTypes(#"Split Column by Delimiter1",{{"Members.1", type text}, {"Members.2", type text}, {"Members.3", type text}, {"Members.4", type text}, {"Members.5", type text}, {"Members.6", type text}, {"Members.7", type text}, {"Members.8", type text}}),
    #"Unpivoted Columns1" = Table.UnpivotOtherColumns(#"Changed Type2", {"Attribute", "Value"}, "Attribute.1", "Value.1"),
    #"Filtered Rows" = Table.SelectRows(#"Unpivoted Columns1", each true),
    #"Split Column by Delimiter2" = Table.SplitColumn(#"Filtered Rows", "Attribute", Splitter.SplitTextByDelimiter(".", QuoteStyle.Csv), {"Attribute.1.1", "Attribute.2"}),
    #"Changed Type3" = Table.TransformColumnTypes(#"Split Column by Delimiter2",{{"Attribute.1.1", type text}, {"Attribute.2", Int64.Type}}),
    #"Split Column by Delimiter3" = Table.SplitColumn(#"Changed Type3", "Attribute.1", Splitter.SplitTextByDelimiter(".", QuoteStyle.Csv), {"Attribute.1.1.1", "Attribute.1.2"}),
    #"Changed Type4" = Table.TransformColumnTypes(#"Split Column by Delimiter3",{{"Attribute.1.1.1", type text}, {"Attribute.1.2", Int64.Type}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type4",{"Attribute.1.1", "Attribute.1.1.1"}),
    #"Added Custom" = Table.AddColumn(#"Removed Columns", "Custom", each if [Attribute.2] = [Attribute.1.2]
then [Value]
else null),
    #"Filtered Rows1" = Table.SelectRows(#"Added Custom", each ([Custom] <> null)),
    #"Removed Columns1" = Table.RemoveColumns(#"Filtered Rows1",{"Attribute.2", "Attribute.1.2", "Value"}),
    #"Removed Duplicates" = Table.Distinct(#"Removed Columns1")
in
    #"Removed Duplicates"

 

Pbix attached.

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
Anonymous
Not applicable

@v-diye-msft 

that worked just great, thank you.

And yes - the string you mentioned was incorrect indeed...

 

Thanks!

amitchandak
Super User
Super User

@Anonymous , In Data Transformation/edit query you have an option for split data into rows and column

https://www.tutorialgateway.org/how-to-split-columns-in-power-bi/

Anonymous
Not applicable

@amitchandak Thank you, I have tried to split the column into new rows by delimiter, at first split the MembersID with the following result:

MemberIDMember
1AB;CD;EF;GH;IJ;KL;MN;OP 
2AB;CD;EF;GH;IJ;KL;MN;OP 
3AB;CD;EF;GH;IJ;KL;MN;OP 
4AB;CD;EF;GH;IJ;KL;MN;OP 
5AB;CD;EF;GH;IJ;KL;MN;OP 
6AB;CD;EF;GH;IJ;KL;MN;OP 
7AB;CD;EF;GH;IJ;KL;MN;OP 
8AB;CD;EF;GH;IJ;KL;MN;OP 

etc.

And then when I have split the Members column I got the following:

MemberIDMember
1AB
1CD
1EF
1GH
1IJ
1KL
1MN
1OP
2AB
2CD
2EF
2GH
2IJ
2KL
2MN
2OP

Etc.

 

I am unable to find a unique combination of MemeberID - Member

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.