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

Comprobación de coincidencias de filas parciales en la misma tabla

Hola Amigos,

Tengo una tabla llamada "Client_Shipments" con las siguientes columnas: [Client_name], [Send_location], [Receive_location], [Coste], [Error_rate]. Estoy tratando de comprobar si para el client_name en cada fila, hay una coincidencia en la misma tabla "Client_Shipments", que tiene los mismos valores para [Send_Location], [Receive_Location], pero no tiene el mismo Client_name.

Básicamente, ¿hay otros clientes que han enviado algo desde el mismo punto de inicio y fin? Los valores [Coste] y [Error_rate] no necesitan coincidir, ya que eso es lo que quiero comparar más adelante. He creado una tabla de ejemplo a continuación, junto con la salida deseada en la columna [Match_found?].

Client_nameSend_locationReceive_locationCostoError_rateMatch_found?
Client_Aacerca deNj$10001%Verdad
Client_AAzel$30010%Verdad
Client_AFlDE$4005%Falso
Client_BPeroCo15003%Falso
Client_BMoSi$5001%Falso
Client_BAzel$4005%Verdad
Client_Bacerca deNj$12001%Verdad

¿Alguna idea de cómo hacer que funcione? Gracias de antemano.

1 ACCEPTED SOLUTION
Smauro
Solution Sage
Solution Sage

Hola @ndeshpande

Puede agregarlo como una nueva columna:

Match_Found_Col =
VAR cl = [Client_name]
VAR sl = [Send_location]
VAR rl = [Receive_location]
VAR c =
    COUNTROWS (
        CALCULATETABLE (
            VALUES ( ClientOrders ),
            FILTER (
                ALL ( ClientOrders ),
                [Send_location] = sl
                    && [Receive_location] = rl
                    && [Client_name] <> cl
            )
        )
    ) + 0
RETURN
    IF ( c > 0, TRUE (), FALSE () )


O como medida:

Match_Found_Mes =
VAR cl =
    FIRSTNONBLANK ( ClientOrders[Client_name], 1 )
VAR sl =
    SELECTEDVALUE ( ClientOrders[Send_location], "123" )
VAR rl =
    SELECTEDVALUE ( ClientOrders[Receive_location], "123" )
VAR c =
    COUNTROWS (
        CALCULATETABLE (
            VALUES ( ClientOrders ),
            FILTER (
                ALL ( ClientOrders ),
                [Send_location] = sl
                    && [Receive_location] = rl
                    && [Client_name] <> cl
            )
        )
    ) + 0
RETURN
    IF ( c > 0, TRUE (), FALSE () )

salud


Editar: Ah, lo siento @parry2k , no había visto su respuesta.




Feel free to connect with me:
LinkedIn

View solution in original post

4 REPLIES 4
Smauro
Solution Sage
Solution Sage

Hola @ndeshpande

Puede agregarlo como una nueva columna:

Match_Found_Col =
VAR cl = [Client_name]
VAR sl = [Send_location]
VAR rl = [Receive_location]
VAR c =
    COUNTROWS (
        CALCULATETABLE (
            VALUES ( ClientOrders ),
            FILTER (
                ALL ( ClientOrders ),
                [Send_location] = sl
                    && [Receive_location] = rl
                    && [Client_name] <> cl
            )
        )
    ) + 0
RETURN
    IF ( c > 0, TRUE (), FALSE () )


O como medida:

Match_Found_Mes =
VAR cl =
    FIRSTNONBLANK ( ClientOrders[Client_name], 1 )
VAR sl =
    SELECTEDVALUE ( ClientOrders[Send_location], "123" )
VAR rl =
    SELECTEDVALUE ( ClientOrders[Receive_location], "123" )
VAR c =
    COUNTROWS (
        CALCULATETABLE (
            VALUES ( ClientOrders ),
            FILTER (
                ALL ( ClientOrders ),
                [Send_location] = sl
                    && [Receive_location] = rl
                    && [Client_name] <> cl
            )
        )
    ) + 0
RETURN
    IF ( c > 0, TRUE (), FALSE () )

salud


Editar: Ah, lo siento @parry2k , no había visto su respuesta.




Feel free to connect with me:
LinkedIn

@Smauro

¡Esto es perfecto, gracias!

parry2k
Super User
Super User

@ndeshpande puede probar el siguiente método

Añadir nueva columna y medida y medida devolverá true/false

Receive and Send Column = 'Table'[Receive_location] & 'Table'[Send_location]


Is Exist Measure = 
VAR __current = VALUES ( 'Table'[Receive and Send Column] )
VAR __client = SELECTEDVALUE ( 'Table'[Client_name] )
VAR __other = CALCULATETABLE ( VALUES ( 'Table'[Receive and Send Column] ), ALL ( 'Table'[Receive and Send Column] ), 'Table'[Client_name] <> __client )
VAR __isExist = CALCULATE ( COUNTROWS ( 'Table' ), INTERSECT ( __other, __current ) ) + 0
RETURN
IF ( __isExist = 0, "False", "True" )

Me gustaría elogiossi mi solución ayudara.👉Si puedes pasar tiempo publicando la pregunta, también puedes hacer esfuerzos para dar a Kudos quien haya ayudado a resolver tu problema. ¡Es una muestra de agradecimiento!

Visítenos enhttps://perytus.com, su ventanilla única para proyectos/formación/consulta relacionados con Power BI.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Gracias por la respuesta rápida, estaba pensando que probablemente tendré que convertir la medida en una columna. Sin embargo, la combinación de los valores de columna separados relevantes en una sola columna fue una gran idea porque simplificará mis búsquedas más adelante.

¡Gracias!

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.