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
Han_Solo
Helper I
Helper I

Suma basada en el recuento de categorías.

Hola

Tengo un problema con la suma contando categorías.
Capture1.PNG

Tengo algunas categorías y más en lugares jerárquicos para ellos. Hay categorías con varios lugares (como Canadá) y hay categorías con un solo lugar. Quiero calcular la SUMA total de value1 para cada categoría, pero cuando la categoría tiene sólo 1 lugar, sumarlos - luego su suma basada en el recuento de la categoría.

Capture2.PNG

así que donde hay AFRICA, ASIA, AUSTRALIA, SUR AMERICA Quiero tener 65,79 (10,92 + 21,69 + 28,98 + 4,20)

Probé diferentes medidas:
(Sé que con uno de abajo no hay condición IF)

AVG_Category = 
VAR _Category = MAX(data[Category])
RETURN 
CALCULATE(SUM(data[Value1]), 
    FILTER(ALL(data[Category], data[Place]), 
        CALCULATE(COUNT(data[Category]), 
            ALL(data[Category], data[Place]), 
                data[Category] = _Category) = 1 ))

o este

AVG_Category1 = 
VAR _cat = MAX(data[Category])
VAR _one = CALCULATE(COUNT(data[Category]), ALL(data[Category], data[Place]), data[Category] = _cat)
RETURN
IF( _one = 1, 
    CALCULATE(SUM(data[Value1]), 
        FILTER(ALL(data[Category], data[Place]), 
            CALCULATE(COUNT(data[Category]), ALL(data[Category], data[Place]), data[Category] = _cat) = 1 )),
    CALCULATE(SUM(data[Value1]), ALL(data), data[Category] = _cat))

pero sin grandes éxitos

Capture3.PNG

pero en lugar de 884,92 debería ser 65,79.

¿Tienes idea de solución? ¿Dónde cometo un error?

Puede descargar el archivo aquí

nota que vale la pena mencionar:

este es el conjunto de datos de ejemplo, el archivo principal tiene dataset de conexión en vivo y mucha fecha, así que intenté llegar a cualquier cosa sin sumx, columnas calculadas, tablas calculadas porque necesitan que sea rápido (a menos que en SSAS)

También se utilizaría en el gráfico de barras apiladas por lo que en el eje sería sólo lugares sin perforación de categoría a través (forma complicada con eje dinámico).

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hola

Puede descargar mi archivo PBI desde aquí.

Espero que esto ayude.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hola

Puede descargar mi archivo PBI desde aquí.

Espero que esto ayude.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
amitchandak
Super User
Super User

@Han_Solo ,

Pruebe como sumx(summarize(data,data[Category],"_max",max(data[Value1])),[_max])

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.