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
jinweitan
Frequent Visitor

Combine two tables creating more rows and columns

Hi,

 

I am trying to combine two tables where:

 

Table 1:

IDQuestion 1Question 2
1AA
2BA

 

Table 2:

IDQuestion 3Question 4
3BC
4CA

 

And hoping to get a result of this:

IDQuestion 1Question 2Question 3Question 4
1AA  
2BA  
3  BC
4  CA

 

Wonder if I can get any advice on this.

 

Many thanks.

1 ACCEPTED SOLUTION
2 REPLIES 2
amitchandak
Super User
Super User
FrankAT
Community Champion
Community Champion

Hi @jinweitan 

you can do it with Power Query like this:

 

// Table 1
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXIE41idaCUjIMsJwosFAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, #"Question 1" = _t, #"Question 2" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Question 1", type text}, {"Question 2", type text}}),
    #"Appended Query" = Table.Combine({#"Changed Type", #"Table 2"})
in
    #"Appended Query"

// Table 2
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlbSUXICYmelWJ1oJRMwS0fJUSk2FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, #"Question 3" = _t, #"Question 4" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Question 3", type text}, {"Question 4", type text}})
in
    #"Changed Type"

 

08-09-_2020_17-33-25.png

 

With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut)

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.