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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
rdiazd73
Helper I
Helper I

combinar consultas

hola power bi-team

agradecere si me pueden ayudar, con un problema para obtener datos de una tabla a otra y que metodo utilizar

table1                                       table2
codigo precio marca          codigo precio marca
1              1           x                 1         ?            ?
1              2           x                  2        ?            ?
2              5           c                  3        ?            ?
3              7           b
3             7,5         b

 

teniendo dos tablas ,

con el mismo dato las dos que seria el codigo

necesito contruir en table 2  el precio y la marca que contiene la table 1

problema en la tabla 1 hay diferentes precios, por lo que podriamos coger el precio mas alto,

como segundo problema es que la tabla 1 contiene mas filas con la marca con lo que al combinar 

me da multiples resultados .

 

gracias x la ayuda

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@rdiazd73 
If you want to create report to include both tables values, you can create a many to one relationship for table 1=>table 2 using [codigo[ column,  then you can put the column in one table visual and do calculation on table 2 using related(table1[column]). 

 

If you want to put 2 tables in 1 table, you can just use merge or append feature in query editor. 

 

Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

@rdiazd73 
If you want to create report to include both tables values, you can create a many to one relationship for table 1=>table 2 using [codigo[ column,  then you can put the column in one table visual and do calculation on table 2 using related(table1[column]). 

 

If you want to put 2 tables in 1 table, you can just use merge or append feature in query editor. 

 

Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

AlB
Community Champion
Community Champion

@rdiazd73 

And in PQ, if you have Table1, these would be the steps from table2:

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

    #"Merged Queries" = Table.NestedJoin(#"Changed Type", {"Codigo"}, Table1, {"codigo"}, "Table1", JoinKind.LeftOuter),
    res = Table.AggregateTableColumn(#"Merged Queries", "Table1", {{"precio", List.Max, "Precio"}, {"marca", List.Max, "marca"}})
in
    res

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

AlB
Community Champion
Community Champion

@rdiazd73 

Create these two calculated columns in Table2

Precio =
CALCULATE (
    MAX ( Table1[Precio] ),
    FILTER ( ALL ( Table1[codigo] ), Table1[codigo] = Table2[codigo] )
)

 

Marca =
CALCULATE (
    MAX ( Table1[Marca] ),
    FILTER ( ALL ( Table1[codigo] ), Table1[codigo] = Table2[codigo] )
)

 

All this can also be done in PQ

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

rdiazd73
Helper I
Helper I

Hello Thank you x look at it

the code always corresponds to the same brand

the problem that has arisen me to merge tables is that Table 1 has hundreds of records

and table 2 a few, and it transforms table 2 into thousands of rows

Best regards

Ricard

AlB
Community Champion
Community Champion

Hi @rdiazd73 

So you want the highest pricein table2. That seems clear. What do you want for the brand? The brand that has the highest price? Another one? Please show the expected result

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.