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
Syndicate_Admin
Administrator
Administrator

Combinar dos tablas por columna

Hola a todos,

Tengo dos tablas con una cantidad diferente de filas. Me pregunto si es posible combinarlos sin interferir con los datos en ninguno de los dos. A continuación se muestran ejemplos de las dos tablas que tengo en mi archivo PBI.

Cotización del clienteCotización del productoPresupuesto de cantidad
manzanaPC1
SamsungTeléfono5

Ventas de clientesProducto de ventasVentas por cantidad
IBMPC3
En FacebookTeléfono1

Esta tabla es el resultado esperado de lo que me gustaría que fuera la combinación de ambas tablas. Los pedidos de fila no importan, solo deseo que se combinen como a continuación.

Cotización del clienteProducto del clienteCantidad del clienteVentas de clientesProducto de ventasVentas por cantidad
manzanaPC1IBMPC3
SamsungTeléfono5En FacebookTeléfono1

¡Gracias!

1 ACCEPTED SOLUTION
Syndicate_Admin
Administrator
Administrator

No @NewPlsHelp ,

use Power Query de la siguiente manera:

14-07-_2021_23-48-08.png

// Table1
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WciwoyElV0lEKcAYShkqxOtFKwYm5xaV56SDBjPw8kKSpUmwsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Customer Quote" = _t, #"Product Quote" = _t, #"Quantity Quote" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Customer Quote", type text}, {"Product Quote", type text}, {"Quantity Quote", Int64.Type}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type)
in
    #"Added Index"

// Table2
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8nTyVdJRCnAGEsZKsTrRSm6JyalJ+fnZINGM/LxUIG2oFBsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Customer Sales" = _t, #"Sales Product" = _t, #"Quantity Sales" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Customer Sales", type text}, {"Sales Product", type text}, {"Quantity Sales", Int64.Type}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type)
in
    #"Added Index"

// MergedTables
let
    Source = Table.NestedJoin(Table1, {"Index"}, Table2, {"Index"}, "Table2", JoinKind.LeftOuter),
    #"Expanded Table2" = Table.ExpandTableColumn(Source, "Table2", {"Customer Sales", "Sales Product", "Quantity Sales"}, {"Customer Sales", "Sales Product", "Quantity Sales"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded Table2",{"Index"})
in
    #"Removed Columns"

Con un cordial saludo desde la ciudad donde la leyenda del 'Gaitero pied de Hamelin' está en casa
FrankAT (Orgulloso de ser un Datanaut)

View solution in original post

2 REPLIES 2
Syndicate_Admin
Administrator
Administrator

No @NewPlsHelp ,

use Power Query de la siguiente manera:

14-07-_2021_23-48-08.png

// Table1
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WciwoyElV0lEKcAYShkqxOtFKwYm5xaV56SDBjPw8kKSpUmwsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Customer Quote" = _t, #"Product Quote" = _t, #"Quantity Quote" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Customer Quote", type text}, {"Product Quote", type text}, {"Quantity Quote", Int64.Type}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type)
in
    #"Added Index"

// Table2
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8nTyVdJRCnAGEsZKsTrRSm6JyalJ+fnZINGM/LxUIG2oFBsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Customer Sales" = _t, #"Sales Product" = _t, #"Quantity Sales" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Customer Sales", type text}, {"Sales Product", type text}, {"Quantity Sales", Int64.Type}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type)
in
    #"Added Index"

// MergedTables
let
    Source = Table.NestedJoin(Table1, {"Index"}, Table2, {"Index"}, "Table2", JoinKind.LeftOuter),
    #"Expanded Table2" = Table.ExpandTableColumn(Source, "Table2", {"Customer Sales", "Sales Product", "Quantity Sales"}, {"Customer Sales", "Sales Product", "Quantity Sales"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded Table2",{"Index"})
in
    #"Removed Columns"

Con un cordial saludo desde la ciudad donde la leyenda del 'Gaitero pied de Hamelin' está en casa
FrankAT (Orgulloso de ser un Datanaut)

Syndicate_Admin
Administrator
Administrator

Estoy seguro de que hay varias maneras de alcanzar su meta. Lo que hago a menudo es abrir Power Query y usar su funcionalidad de combinación.

En la pestaña Inicio de Power Query, haga clic en la flecha desplegable Combinar consultas y seleccione Combinar consultas como nuevas. Creará una nueva tabla combinada mientras deja sus 2 tablas originales como estaban.

dudeyates_1-1626297128413.png

Tendrá la opción de seleccionar qué tablas combinar y por qué columna desea combinar.

Esta introducción a las consultas de combinación de documentación de Microsoft debería ayudar

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.