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

Matriz con recuento haciendo coincidir filas y columnas

¡Hola a todos!
Basado en estas tablas de datos como ejemplo:


Match.jpg


Quiero hacer coincidir los productos en pares, no importa el orden, por ejemplo, para el cliente "C": Case-Mouse, Case-Notebook, Mouse-Notebook, Mouse-Case, Notebook Notebook, Notebook-Case, Notebook-Case, Notebook-Case. Cuando coincide en una columna y una fila, contará 1.

Intenté muchas cosas (siempre trabajando con una matriz como el objeto visual). Hice una mesa duplicada para Productos(Tabla 2)para poner uno como una columna y el otro como Fila.


Match_Products de la zona de la zona de
CALCULATE(COUNT('Table1'[Cliente]),
FILTRO('Tabla1',
'Table1'[Cliente] 'Table1'[Cliente]&&
'Table1'[Producto] ?MAX('Table2'[Producto])&&
'Table1'[Product] =MAX('Table2 (2)'[Producto])
)
)
Además, intenté con LOOKUPTABLE, o usando Power Query con columnas dinámicas... pero nada funciona para mí.

Cualquier ayuda sería apreciada. ¡Gracias!

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User
3 REPLIES 3
dax
Community Support
Community Support

Hola @lgargallo ,

Según su salida esperada, no entiendo su lógica, ¿quería cruzar la mesa? Si es posible, ¿podría explicar esto en detalle? Si desea combinar la tabla, puede usar el código debajo de M para ver si funciona o no

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUfLNLy1OVYrViVZyAvK8UyuT8hOLUsACzkAB50SorDOKWhDPL78kNSk/Pxss4IIu4IQu4IpigCO6ZS4o0q5wq2MB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Client = _t, Product = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Client", type text}, {"Product", type text}}),
    #"Merged Queries" = Table.NestedJoin(#"Changed Type", {"Client"}, #"Changed Type", {"Client"}, "Changed Type", JoinKind.FullOuter),
    #"Expanded Changed Type" = Table.ExpandTableColumn(#"Merged Queries", "Changed Type", {"Client", "Product"}, {"Client.1", "Product.1"})
in
    #"Expanded Changed Type"

724.PNG

Saludos
Zoe Zhi

Si este post ayuda, por favor considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

az38
Community Champion
Community Champion

Hola @lgargallo

Tratar:

1. cambie el nombre de la columna Tabla2[Producto] a Tabla2[Producto2]

2.

crear una nueva tabla

Table = 
ADDCOLUMNS(
 CROSSJOIN('Table 1','Table 2'),
 "CrossCount", 
 CALCULATE(
  COUNTROWS('Table 1'),
  FILTER(
   ALL('Table 1'),
   'Table 1'[Client]=EARLIER('Table 1'[Client]) && 'Table 1'[Product] = EARLIER('Table 2'[Product2])
  )
 )
)

3. poner en la tabla de matriz[Producto] como filas, Tabla [Producto2] como columnas y SUM CrossCount como valores


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

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.