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
Isa-TheHague
Frequent Visitor

Múltiples categorías, reemplace category_ID por category_ID más grandes

Hola a todos

Hace poco pedí ayuda aquí con un conjunto de datos que contiene varias categorías por producto: https://community.powerbi.com/t5/Desktop/See-if-product-is-in-more-than-one-category/m-p/1291151

Las soluciones dadas funcionan y ahora quiero reescribir el category_ID con la categoría más grande para ese producto.

Product_IDCategory_IDNew_Category_IDSales_QTYCheck_multiple_categories
0010010017Falso
002001002
1
Verdad
002002002
15
Verdad
0030010015Falso
0030010012Falso

Así que la categoría más grande es la categoría que tiene más ventas en ella, como se ve en el ejemplo de producto 002 está en las categorías 001 y 002, 002 siendo el más grande. La salida deseada sería 002 para ambos registros.

He estado estrangulando con esto durante horas, buscando en la web, pero no he encontrado una solución que funcione todavía. Estaba pensando tal vez una columna calculada que SI check_multiple_categories verdadero y luego devolver el mayor category_id más category_id

¿Hay alguna manera de hacerlo en Power BI/Query?

¡Saludos!

Isa

2 ACCEPTED SOLUTIONS
V-pazhen-msft
Community Support
Community Support

@Isa-TheHague

Intente crear la siguiente columna dax:

Column = 
var max_ = CALCULATE(MAX([Sales_QTY]),ALLEXCEPT('Table','Table'[Product ID]),FILTER('Table',[Check_multiple_categories]=true))
Return IF([Check_multiple_categories]=TRUE(),CALCULATE(MAX([Category_ID]),FILTER('Table',[Sales_QTY]=max_)),[Category_ID])

max sales cato.JPG


Paul Zheng _ Equipo de apoyo de la comunidad
Si este post ayuda, entonces considera Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

View solution in original post

@V-pazhen-msft

Gracias por su respuesta, funcionó después de un pequeño acuse de año:

New_Cat =
var max_ = CALCULATE( 
MAX([Sales_QTY]),
FILTER(Example_Table,'Example_Table'[Product_ID] = EARLIER(Example_Table[Product_ID])),
FILTER(Example_Table,[Check_multiple_categories]=true))


Return IF(
[Check_multiple_categories]=TRUE(),
CALCULATE(
MAX([Category_ID]),
FILTER('Example_Table',[Sales_QTY]=max_)),
[Category_ID])

View solution in original post

3 REPLIES 3
V-pazhen-msft
Community Support
Community Support

@Isa-TheHague

Intente crear la siguiente columna dax:

Column = 
var max_ = CALCULATE(MAX([Sales_QTY]),ALLEXCEPT('Table','Table'[Product ID]),FILTER('Table',[Check_multiple_categories]=true))
Return IF([Check_multiple_categories]=TRUE(),CALCULATE(MAX([Category_ID]),FILTER('Table',[Sales_QTY]=max_)),[Category_ID])

max sales cato.JPG


Paul Zheng _ Equipo de apoyo de la comunidad
Si este post ayuda, entonces considera Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

@V-pazhen-msft

Gracias por su respuesta, funcionó después de un pequeño acuse de año:

New_Cat =
var max_ = CALCULATE( 
MAX([Sales_QTY]),
FILTER(Example_Table,'Example_Table'[Product_ID] = EARLIER(Example_Table[Product_ID])),
FILTER(Example_Table,[Check_multiple_categories]=true))


Return IF(
[Check_multiple_categories]=TRUE(),
CALCULATE(
MAX([Category_ID]),
FILTER('Example_Table',[Sales_QTY]=max_)),
[Category_ID])

lbendlin
Super User
Super User

Puesto que desea buscar en todos los identificadores de categoría para cada producto, debe quitar el contexto de filtro para el identificador de categoría mientras mantiene intactos todos los demás contextos de filtro. A continuación, realice el cálculo MAX() y asigne el resultado a la nueva medida.

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.