cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
__BigDaddy
Frequent Visitor

Power Query - transform a column of value in two columns of all couple of values

Dear all,

I have a need and did not find a solution. 
let's say I have Family of product, each of them contains a population of items.
I must calculate the % of common items between each family. I'd like to represent it under a triangle matrix with the Family list on both dimensions.

For this I am thinking about create a table of Family couple and then create a calculated row in PBI to count my common items; Is it possible to do this in power query? I tried with duplicate column, unpivoting, transposed, but cannot find a solution.
Here is an illustration: 

 

The current table :

Family 

A

B

C

 

The expected couple table :
Family_1    Family_2

A               A

A               B

A               C

B               A

B               B

B               C

C               A

C               B

C               C

Thanks a lot,

1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test (later on when you use the query on your dataset, you will have to change the source appropriately.)

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclSK1YlWcgKTzkqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Family = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Custom", each Source[Family]),
    #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom")
in
    #"Expanded Custom"

 

View solution in original post

2 REPLIES 2
__BigDaddy
Frequent Visitor

Worked very well, 

Thanks again @Vijay_A_Verma

 

Have a nice day

Vijay_A_Verma
Super User
Super User

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test (later on when you use the query on your dataset, you will have to change the source appropriately.)

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclSK1YlWcgKTzkqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Family = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Custom", each Source[Family]),
    #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom")
in
    #"Expanded Custom"

 

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors