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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Joining Headers in one table with a Column in another

Hi All

 

So, I have a list of countries as a table with each country being a header of a column and having some values within said column

 

I am trying to bring it into the model and link it with a fact table I have, which also contains a list of countries but as a column

 

So, essentially a table like this:

ED95_0-1669893906647.png

 

 

To be joined to they key fact table in the model that has list of countries as a row

ED95_1-1669893975828.png


Any advise will be greatly appriciated! 

 



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

Hi @Anonymous 

 

These countries cannot be associated with another table when they are columns, you can convert them into rows in Power Query and then establish relationships, and then enter the following code in Advanced Editor

 

let

    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlbSUTICYhMgNlWK1YGImAKxMVgUJGICFQHR5kqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Argentina = _t, Armenia = _t, Brazil = _t, Ghana = _t]),

    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Argentina", Int64.Type}, {"Armenia", Int64.Type}, {"Brazil", Int64.Type}, {"Ghana", Int64.Type}}),

    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {}, "Attribute", "Value"),

    #"Renamed Columns" = Table.RenameColumns(#"Unpivoted Columns",{{"Attribute", "Country"}})

in

    #"Renamed Columns"

 

vxinruzhumsft_0-1669961904751.png

 

 

The report is then applied to the report, and then a relationship is established with another table

 

vxinruzhumsft_1-1669961904753.png

 

 

Best Regards,

Yolo Zhu

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

2 REPLIES 2
Anonymous
Not applicable

Thank you!

 

That's great help!

v-xinruzhu-msft
Community Support
Community Support

Hi @Anonymous 

 

These countries cannot be associated with another table when they are columns, you can convert them into rows in Power Query and then establish relationships, and then enter the following code in Advanced Editor

 

let

    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlbSUTICYhMgNlWK1YGImAKxMVgUJGICFQHR5kqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Argentina = _t, Armenia = _t, Brazil = _t, Ghana = _t]),

    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Argentina", Int64.Type}, {"Armenia", Int64.Type}, {"Brazil", Int64.Type}, {"Ghana", Int64.Type}}),

    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {}, "Attribute", "Value"),

    #"Renamed Columns" = Table.RenameColumns(#"Unpivoted Columns",{{"Attribute", "Country"}})

in

    #"Renamed Columns"

 

vxinruzhumsft_0-1669961904751.png

 

 

The report is then applied to the report, and then a relationship is established with another table

 

vxinruzhumsft_1-1669961904753.png

 

 

Best Regards,

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.