Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric certified for FREE! Don't miss your chance! Learn more

Reply
TesterDiseño
New Member

PowerBi Matriz Ranking Cliente Articulo

Estimados,

 

Quiero hacer una matriz de cliente (columnas) y articulo (filas). Tienen que aparecerme el top10 de cada una.

 

Puede ser que el cliente A sera el n° 5, y con el articulo 5° no tenga ninguna venta. En ese caso, me mostrara con valor 0. De esta forma vere oportunidades de mejora.

 

La pregunta es, como puedo hacer que las filas y columnas respeten el orden del ranking global?

 

Hay alguna visual que me de ordenes personalizados a las columnas y filas?

 

Desde ya gracias.

 

Sds.,

 

 

1 ACCEPTED SOLUTION
v-tejrama
Community Support
Community Support

Hi  @TesterDiseño ,

Thanks for reaching out to the Microsoft fabric community forum.

 

To sort a matrix in Power BI by each customer's total sales for the year 2022, start by creating a Calendar table and building a relationship with the Sales table using the Date column. Then, define a DAX measure to rank customers based on their 2022 sales using the formula:

 

Here is the DAX :

Rank 2022 = IF(ISINSCOPE(Sales[Customer]), RANKX(ALL(Sales[Customer]), CALCULATE(SUM(Sales[Sales Value]), 'Calendar'[Year] = 2022), , DESC, SKIP))


Add a matrix visual with Customer in Rows, Product in Columns (optional), and Sales Value in the Values area.

Include the Rank 2022 measure (either in Values or Tooltip), then sort the matrix by Rank 2022 in descending order. This approach displays customers ordered by their total sales in 2022, even if other slicers are applied

 

Please find the attached pbix file for your reference.

 

Best Regards,

Tejaswi.

Community Support

View solution in original post

7 REPLIES 7
v-tejrama
Community Support
Community Support

Hi  @TesterDiseño ,

Thanks for reaching out to the Microsoft fabric community forum.

 

To sort a matrix in Power BI by each customer's total sales for the year 2022, start by creating a Calendar table and building a relationship with the Sales table using the Date column. Then, define a DAX measure to rank customers based on their 2022 sales using the formula:

 

Here is the DAX :

Rank 2022 = IF(ISINSCOPE(Sales[Customer]), RANKX(ALL(Sales[Customer]), CALCULATE(SUM(Sales[Sales Value]), 'Calendar'[Year] = 2022), , DESC, SKIP))


Add a matrix visual with Customer in Rows, Product in Columns (optional), and Sales Value in the Values area.

Include the Rank 2022 measure (either in Values or Tooltip), then sort the matrix by Rank 2022 in descending order. This approach displays customers ordered by their total sales in 2022, even if other slicers are applied

 

Please find the attached pbix file for your reference.

 

Best Regards,

Tejaswi.

Community Support

V-tejrama,

 

Thanks a lot for you answer.

 

Best regards.,

Hi @TesterDiseño ,

 

Just checking in have you been able to resolve this issue? If so, it would be greatly appreciated if you could mark the most helpful reply accordingly. This helps other community members quickly find relevant solutions.

 

Thank you.

TesterDiseño
New Member

Gracias por la respuesta. No es exactamente lo que busco. Paso un ejemplo para dar claridad.

En una matriz de 2000 clientes y 20.000 articulos.

 

Quiero sacar el top5 de cada uno y ver como participan entre si.

 

Datos de ejemplo:

 

Ventas por Cliente (Ranking Global)
Ranking GlobalClienteVenta
1Juan$ 100,00
2Pedro$ 90,00
3Mario$ 80,00
4Jose$ 70,00
5Mario$ 60,00

 

Ventas por Articulo  (Ranking Global)
Ranking GlobalArticuloVenta
1Silla$ 1.500,00
2Mesa$ 950,00
3Ropero$ 850,00
4Sillon$ 710,00
5Cama$ 600,00

 

Matriz a generar:

Matriz
 JuanPedroMarioJoseMario
Silla$ 10,00$ 0,00$ 10,00$ 0,00$ 4,00
Mesa$ 8,00$ 0,00$ 5,00$ 0,00$ 5,00
Ropero$ 0,00$ 0,00$ 4,00$ 0,00$ 0,00
Sillon$ 12,00$ 0,00$ 0,00$ 0,00$ 0,00
Cama$ 0,00$ 0,00$ 0,00$ 20,00$ 1,00

 

Para hacer la matriz, tengo el detalle de como esta compuesta por articulo/cliente los valores que estan indicados en los ranking globales.

Necesito que en funcion de estos ranking globales, se ordenen las columnas y las filas. Va haber mas de una columna.

 

Inclusive, lo trataria de ver en una headmap para que visualmente se vean oportunidades de mejora. En las medidas nativas de power bi no encontre como hacerlo.

 

Desde ya muchas gracias por la ayuda.

Thanks for the clarification, This cannot be done natively with just Power BI's matrix visual as it doesn't allow dynamic TopN across both rows and columns simultaneously. may be you can try with possibly a custom visual you can achieve it.

custom charts like: xViz Heatmap, Deneb.

Deneb: Declarative Visualization in Power BI | Deneb

 

 

Hope the above information helps.

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Muchas gracias por la respuesta.

 

Probe con Deneb, pero me encontre con el siguiente inconveniente.

Creo una medida para ver el ranking total de cliente y de articulo, y cargo la misma en Denebe junto con las otras variables.

 

 

    "filter": "datum.RankClienteDAX_Global <= 10 || datum.RankArticuloDAX_Global <= 10"

 

Cuando defino que clientes y articulos va mostrarme, si utilizo "||" me trae muchos mas de 10, me trae todos los de la seria. Si utilizo "&&" como separador, me trae solo 10, pero de existiir algun articulo del top10 que no se cruce con ningun cliente del top10, me lo saltea, lo excluye del ranking, por mas que forme parte de los 10 del ranking global. Lo mismo para con cliente, si tengo un cliente del rankin 10, que no ha comprado ninguno de los articulos del ranking 10, me lo exlcuye.

En la muestra de datos de ejemplo que pase, "Pedro" seria excluido con con el separador "&&" (and), me traeria otro, teniendo al mismo por inexistente por ser blank.

 

Si le pongo "||" (or) me traeria muchos mas registros.


Estuve dando vueltas en json y hasta busque mejorar el codigo con las IA, pero no consegui resolverlo. Tal vez si hubiera una forma en json de limitar los campos/filas que aparecen podria usarlo con "||", aunque tengo entendido que Deneb no lo permite.

 

Muchas gracias por la molestia.

rajendraongole1
Super User
Super User

Hi @TesterDiseño  - Below are few of the solved threads and YT link:

Solved: Top N Within Matrix Table - Microsoft Fabric Community

Power BI: Dynamically top N rank for multiple columns in the matrix using RANKX, SWITCH & ISINSCOPE

 

Hope this helps.

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.