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.
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
Id | Cliente |
1 | Marc |
2 | Jean |
3 | Anna |
4 | Sandrine |
5 | Juliette |
Tabla de ventas
Customerid | Productid |
1 | 1 |
1 | 2 |
1 | 3 |
2 | 5 |
3 | 4 |
3 | 5 |
4 | 2 |
4 | 5 |
5 | 1 |
5 | 2 |
5 | 3 |
5 | 4 |
5 | 5 |
Tabla de productos
Id | Producto |
1 | Iphone |
2 | Queso |
3 | Bistec |
4 | Computadora |
5 | Playstation |
Gracias
Solved! Go to 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
@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.
@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
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 |
User | Count |
---|---|
2 | |
2 | |
2 | |
2 | |
1 |