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

Unir dos tablas con dos variables

Hola, soy nuevo en powerBI y estoy practicando con un panel personalizado, hasta ahora tan bueno, pero ahora estoy tratando de mostrar mis datos de una manera amigable y no puedo encontrar una manera.

Esto es lo que tengo:

Tabla de formación:

MatchIDPlayer_NameTeam_Initials
1091Segundo DURANDALera
1091René Fernández

era

1091Ellos Luisbien
1091Vellosobien

Tabla WorldCupMatches (solo incluyo las columnas que siento que son relevantes):

MatchIDHome_Team_InitialsAway_Team_Initials
1091bienera

Resultado previsto:

MatchIDHome_Team_PlayersHome_Team_InitialsAway_Team_InitialsAway_Team_Players
1091Ellos LuisbieneraSegundo DURANDAL
1091VellosobieneraRené Fernández

Ninguna de mis fórmulas DAX funcionó hasta ahora y estoy dudando de que si es posible, cualquier ayuda sería apreciada!

1 ACCEPTED SOLUTION
Syndicate_Admin
Administrator
Administrator

Hay @Radgost,

Puede probar esto en Power Query:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjSwNFTSUQpOTS/NS8lXcAkNcvRzcfQBCjn5+yjF6sBVBKXmpSq4pRblJealpFZhykelKviUZhaDJIIckSXCUnNy8ovzYRKxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [MatchID = _t, Player_Name = _t, Team_Initials = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"MatchID", Int64.Type}, {"Player_Name", type text}, {"Team_Initials", type text}}),
    #"Merged Queries" = Table.NestedJoin(#"Changed Type", {"MatchID"}, #"WorldCupMatches Table", {"MatchID"}, "WorldCupMatches Table", JoinKind.LeftOuter),
    #"Expanded WorldCupMatches Table" = Table.ExpandTableColumn(#"Merged Queries", "WorldCupMatches Table", {"MatchID", "Home_Team_Initials", "Away_Team_Initials"}, {"WorldCupMatches Table.MatchID", "WorldCupMatches Table.Home_Team_Initials", "WorldCupMatches Table.Away_Team_Initials"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded WorldCupMatches Table",{"WorldCupMatches Table.MatchID"}),
    #"Added Custom" = Table.AddColumn(#"Removed Columns", "Custom", each if [Team_Initials]=[WorldCupMatches Table.Home_Team_Initials] 
then 1
else 0),
    #"Renamed Columns" = Table.RenameColumns(#"Added Custom",{{"WorldCupMatches Table.Home_Team_Initials", "Home_Team_Initials"}, {"WorldCupMatches Table.Away_Team_Initials", "Away_Team_Initials"}}),
    #"Removed Columns1" = Table.RemoveColumns(#"Renamed Columns",{"Team_Initials"}),
    #"Filtered Rows1" = Table.SelectRows(#"Removed Columns1", each ([Custom] = 0)),
    #"Filtered Rows" = Table.SelectRows(#"Removed Columns1", each ([Custom] = 1)),
    Custom1 = Table.AddColumn(#"Filtered Rows","tableA",each #"Filtered Rows1"[Player_Name]),
    Custom2 = Table.AddColumn(#"Custom1","tableB",each if [Player_Name]=List.Min(#"Custom1"[Player_Name]) then List.Min([tableA]) else List.Max([tableA])),
    #"Removed Columns2" = Table.RemoveColumns(Custom2,{"tableA", "Custom"}),
    #"Renamed Columns1" = Table.RenameColumns(#"Removed Columns2",{{"Player_Name", "Home_Team_Players"}, {"tableB", "Away_Team_Players"}})
in
    #"Renamed Columns1"

Aquí está la salida:

v-xulin-mstf_0-1622537415792.png

Por favor, pruebe el pbix adjunto.

Saludos
enlace

Si esta publicación ayuda, por favor considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

View solution in original post

4 REPLIES 4
Syndicate_Admin
Administrator
Administrator

Hay @Radgost,

Puede probar esto en Power Query:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjSwNFTSUQpOTS/NS8lXcAkNcvRzcfQBCjn5+yjF6sBVBKXmpSq4pRblJealpFZhykelKviUZhaDJIIckSXCUnNy8ovzYRKxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [MatchID = _t, Player_Name = _t, Team_Initials = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"MatchID", Int64.Type}, {"Player_Name", type text}, {"Team_Initials", type text}}),
    #"Merged Queries" = Table.NestedJoin(#"Changed Type", {"MatchID"}, #"WorldCupMatches Table", {"MatchID"}, "WorldCupMatches Table", JoinKind.LeftOuter),
    #"Expanded WorldCupMatches Table" = Table.ExpandTableColumn(#"Merged Queries", "WorldCupMatches Table", {"MatchID", "Home_Team_Initials", "Away_Team_Initials"}, {"WorldCupMatches Table.MatchID", "WorldCupMatches Table.Home_Team_Initials", "WorldCupMatches Table.Away_Team_Initials"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded WorldCupMatches Table",{"WorldCupMatches Table.MatchID"}),
    #"Added Custom" = Table.AddColumn(#"Removed Columns", "Custom", each if [Team_Initials]=[WorldCupMatches Table.Home_Team_Initials] 
then 1
else 0),
    #"Renamed Columns" = Table.RenameColumns(#"Added Custom",{{"WorldCupMatches Table.Home_Team_Initials", "Home_Team_Initials"}, {"WorldCupMatches Table.Away_Team_Initials", "Away_Team_Initials"}}),
    #"Removed Columns1" = Table.RemoveColumns(#"Renamed Columns",{"Team_Initials"}),
    #"Filtered Rows1" = Table.SelectRows(#"Removed Columns1", each ([Custom] = 0)),
    #"Filtered Rows" = Table.SelectRows(#"Removed Columns1", each ([Custom] = 1)),
    Custom1 = Table.AddColumn(#"Filtered Rows","tableA",each #"Filtered Rows1"[Player_Name]),
    Custom2 = Table.AddColumn(#"Custom1","tableB",each if [Player_Name]=List.Min(#"Custom1"[Player_Name]) then List.Min([tableA]) else List.Max([tableA])),
    #"Removed Columns2" = Table.RemoveColumns(Custom2,{"tableA", "Custom"}),
    #"Renamed Columns1" = Table.RenameColumns(#"Removed Columns2",{{"Player_Name", "Home_Team_Players"}, {"tableB", "Away_Team_Players"}})
in
    #"Renamed Columns1"

Aquí está la salida:

v-xulin-mstf_0-1622537415792.png

Por favor, pruebe el pbix adjunto.

Saludos
enlace

Si esta publicación ayuda, por favor considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

Hola Enlace! Gracias por esto! es exactamente lo que necesitaba. Aun así i'm actualmente enfrentando un asunto con esta línea y es debido a un error i hizo mientras escribí el correo. Los datos se dividen en dos archivos .csv, uno llamado "WorldCupMatches" y el otro llamado "WorldCupPlayers". Así que al llegar a este paso "= Table.TransformColumnTypes(Origen,{{"MatchID", Int64.Type}, {"Player_Name", escriba text}, {"Team_Initials", escriba text}})"

Se producirá un error en la consulta ya que la columna "Player_Name" está actualmente en un archivo diferente.

Voy a tratar de averiguarlo mientras tanto, pero cualquier puntero será apreciado.

Gracias de nuevo!

Syndicate_Admin
Administrator
Administrator

@Radgost , si la segunda tabla tiene un IDENTIFICADOR de coincidencia único, a continuación, simplemente unirse a los dos en match ID crear 1-M join(in data model) y usarlos en visual juntos

Si lo entendí correctamente, eso traerá los campos de una tabla a otra, pero no ayudará con la selección de campos creo, quise que la tabla final se mostrara al seleccionar un MatchID.

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.

Top Solution Authors