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

Clientes que compraron el producto A y B pero no el producto C

Oye, estoy teniendo problemas con esto.

Tengo 3 mesas :

- Clientes

- Productos

- Ventas

La tabla "Ventas" es el vínculo entre "Clientes" y "Productos".

Lo que necesito conseguir son clientes que compraron el producto A pero no el producto B y C. O los clientes que compraron productos B y C pero no A, etc...

Aquí están los datos de muestra:

Tabla de clientes

IdCliente
1Marc
2Jean
3Anna
4Sandrine
5Juliette

Tabla de ventas

CustomeridProductid
11
12
13
25
34
35
42
45
51
52
53
54
55

Tabla de productos

IdProducto
1Iphone
2Queso
3Bistec
4Computadora
5

Playstation

Gracias

1 ACCEPTED SOLUTION

Hola @Axel777,

Puede crear una tabla de cálculo con registros de tabla 'products' y usarla como campo de origen de la segmentación de datos, luego escribir una fórmula de medida y usarla en 'filtro de nivel visual' para filtrar registros.

Calcular tabla:

PSelector = Products

Medida:

Measure = 
VAR selected =
    VALUES( PSelector[ID] )
VAR rcList =
    CALCULATETABLE (
        VALUES ( Sales[CustomerID] ),
        FILTER ( ALLSELECTED(  Sales ), [ProductID] IN selected )
    )
VAR summary =
    SUMMARIZE (
        FILTER ( ALLSELECTED(  Sales ), [CustomerID] IN rcList ),
        [CustomerID],
        "Condition",
        var productList=CALCULATETABLE( VALUES ( Sales[ProductID] ),ALLSELECTED(Sales),VALUES(Sales[CustomerID]))
        VAR rowCount =
            COUNTROWS (productList)
        VAR _intersect =
            INTERSECT ( productList, selected )
        RETURN
            COUNTROWS ( selected ) = rowCount
            && COUNTROWS ( selected ) = COUNTROWS ( _intersect )
    )
RETURN
   IF (
        SELECTEDVALUE ( Customers[ID] )
            IN SELECTCOLUMNS ( FILTER ( summary, [Condition] = TRUE () ), "ID", [CustomerID] ),
        "Y",
        "N"
    )

También adjunto el archivo de muestra a continuación, se puede comprobar si ayuda.

saludos

Xiaoxin Sheng

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

View solution in original post

4 REPLIES 4
parry2k
Super User
Super User

@Axel777 adjunté si funciona, lo hice hace mucho tiempo para una pregunta similar.

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



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.

Anonymous
Not applicable

@parry2k Está en el mismo espíritu, pero no exactamente lo que quiero.

Estos son algunos ejemplos:

- Si selecciono el producto 4 en mi lista de productos, necesito ver a los clientes que solo compraron el producto 4. Si el cliente 2 compró productos 4 y 5, no mostrará a este cliente ya que también compró el producto 5.

- Si selecciono los productos 2 y 3 en mi lista de productos, necesito ver clientes que solo compraron productos 2 y 3. Si el cliente 3 compró productos 2, 3 y 4 no mostrará a este cliente ya que también compró el producto 4.

Tengo más de 30 productos por lo que tiene que ser general.

Hola @Axel777,

Puede crear una tabla de cálculo con registros de tabla 'products' y usarla como campo de origen de la segmentación de datos, luego escribir una fórmula de medida y usarla en 'filtro de nivel visual' para filtrar registros.

Calcular tabla:

PSelector = Products

Medida:

Measure = 
VAR selected =
    VALUES( PSelector[ID] )
VAR rcList =
    CALCULATETABLE (
        VALUES ( Sales[CustomerID] ),
        FILTER ( ALLSELECTED(  Sales ), [ProductID] IN selected )
    )
VAR summary =
    SUMMARIZE (
        FILTER ( ALLSELECTED(  Sales ), [CustomerID] IN rcList ),
        [CustomerID],
        "Condition",
        var productList=CALCULATETABLE( VALUES ( Sales[ProductID] ),ALLSELECTED(Sales),VALUES(Sales[CustomerID]))
        VAR rowCount =
            COUNTROWS (productList)
        VAR _intersect =
            INTERSECT ( productList, selected )
        RETURN
            COUNTROWS ( selected ) = rowCount
            && COUNTROWS ( selected ) = COUNTROWS ( _intersect )
    )
RETURN
   IF (
        SELECTEDVALUE ( Customers[ID] )
            IN SELECTCOLUMNS ( FILTER ( summary, [Condition] = TRUE () ), "ID", [CustomerID] ),
        "Y",
        "N"
    )

También adjunto el archivo de muestra a continuación, se puede comprobar si ayuda.

saludos

Xiaoxin Sheng

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

@v-shex-msft Lo implementé con éxito. Muchas gracias, eres el mejor !

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.