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

Comparar si un valor está en otra tabla y viceversa

Hola a todos,

Tengo dos mesas:
Tabla1

COD_1
001
002
003


Tabla2

COD_2
001
002
008


Me gustaría comparar la columna COD de Table1 con la columna COD de Table2. Cada valor de estas dos columnas nunca se repite.
Así que me gustaría crear una tercera tabla que muestre los COD y dos columnas denominadas Table1 y Table2. Cada una de estas columnas informa si el COD respectivo está en la tabla 1 o la tabla 2, o en ambas tablas.
La mesa sería algo como esto:

COD_newTableTabla1Tabla2
001
002
003No
008No


¿Puede alguien ayudarme, por favor?

3 REPLIES 3
v-shex-msft
Community Support
Community Support

HI @req7,

Puede utilizar la función de unión para combinar estos registros y utilizar el operador 'in' para comprobar si existían en registros de tabla específicos:

Table =
SUMMARIZE (
    SELECTCOLUMNS ( UNION ( ALL ( T1[COD_1] ), ALL ( T2[COD_2] ) ), "COD", [COD_1] ),
    [COD],
    "T1", [COD] IN VALUES ( T1[COD_1] ),
    "T2", [COD] IN VALUES ( T2[COD_2] )
)

saludos

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
vanessafvg
Super User
Super User

también puede hacerlo en la consulta de energía, consulte adjunto.





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




az38
Community Champion
Community Champion

Hola @req7

crear una tabla calculada

Table = 
ADDCOLUMNS(
DISTINCT(
    UNION(
        SELECTCOLUMNS(Table1,"COD",Table1[COD_1]),
        SELECTCOLUMNS(Table2,"COD",Table2[COD_2])
    )
),
"Table1", IF(CALCULATE(COUNTROWS(Table1),Table1[COD_1]=EARLIER([COD])) > 0, "Yes", "No"),
"Table2", IF(CALCULATE(COUNTROWS(Table2),Table2[COD_2]=EARLIER([COD])) > 0, "Yes", "No")
)

a continuación, añadir poner sus campos a la visual


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

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.