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
Syndicate_Admin
Administrator
Administrator

Cómo calcular el subtotal de otras filas (excluir el valor de fila actual)

Estoy buscando una manera de generar una columna subtotal que sea la suma de otras filas de datos, por lo que, en otras palabras, omite / excluye el valor de la fila actual del subtotal.

  • Según la captura de pantalla siguiente, quiero crear lo que se muestra en el col D (metric1_subtotal_other filas).
    • Col E contiene ejemplos de cómo estoy llegando a los subtotales que me gustaría crear
  • Ya tengo valores en cols A-C en mi informe PBI.

Trend_test_ss.JPG

En caso de que sea necesario, puede acceder al informe PBI de ejemplo aquí:

https://drive.google.com/file/d/1vGtN2pr8zHD_MSxANbs63KMcueOTcUPz/view?usp=sharing

Además, aquí hay un enlace al archivo de Excel utilizado para crear el archivo PBI y la captura de pantalla anterior: https://drive.google.com/file/d/19spH03FeAMPh6SWE2zTYqFsSy8cWeHl8/view?usp=sharing

1 ACCEPTED SOLUTION

@hashariprueba esto

_test = 
IF (
    OR (
        OR ( ISINSCOPE ( SM[srg] ), ISINSCOPE ( SM[sds] ) ),
        ISINSCOPE ( SM[loc] )
    ),
    CALCULATE ( SUM ( CS1[metric1_subtotal] ), ALLSELECTED ( CS1 ) )
        - SUMX ( CS1, CS1[metric1_subtotal] ),
    IF (
        HASONEVALUE ( SM[sdv] ),
        VAR _1 =
            MAX ( SM[sdv] )
        VAR _2 =
            CALCULATE (
                SUMX ( CS1, CS1[metric1_subtotal] ),
                FILTER ( ALLSELECTED ( SM ), SM[sdv] <> _1 )
            )
        RETURN
            _2,
        SUMX ( CS1, CS1[metric1_subtotal] )
    )
)

View solution in original post

6 REPLIES 6
Syndicate_Admin
Administrator
Administrator

@hasharipuedes probar esto como medida?

_x := 
IF (
    HASONEVALUE ( SM[sdv] ),
    VAR _1 =
        MAX ( SM[sdv] )
    VAR _2 =
        CALCULATE (
            SUMX ( CS1, CS1[metric1_subtotal] ),
            FILTER ( ALLSELECTED ( SM ), SM[sdv] <> _1 )
        )
    RETURN
        _2,
    SUMX ( CS1, CS1[metric1_subtotal] )
)

Capture.PNG

@smpa01 - ¡Gracias por compartir este enfoque!

Parece funcionar bien en el nivel 'sdv' (Nivel-1), pero cuando perforo hasta 'srg' (Nivel-2), no parece seguir las filas de nivel de perforación.

hashari_0-1614792978559.png

¿Pensamientos?

@hashari prueba esto y comprueba si funciona como quieras

Measure :=
IF (
    OR (
        OR ( ISINSCOPE ( SM[srg] ), ISINSCOPE ( SM[sds] ) ),
        ISINSCOPE ( SM[loc] )
    ),
    SUMX ( CS1, CS1[metric1_subtotal] ),
    IF (
        HASONEVALUE ( SM[sdv] ),
        VAR _1 =
            MAX ( SM[sdv] )
        VAR _2 =
            CALCULATE (
                SUMX ( CS1, CS1[metric1_subtotal] ),
                FILTER ( ALLSELECTED ( SM ), SM[sdv] <> _1 )
            )
        RETURN
            _2,
        SUMX ( CS1, CS1[metric1_subtotal] )
    )
)

@hashari No estoy seguro de cómo imagina el cálculo para salir en un nivel de perforación hacia abajo

En el nivel individualsdv (contexto de filtro no subtotal), estoy diciendo a mi medida que calcule el evrything pero ese nivel de sdv en particular. Así que con sdv=2, resume 4+5+7+10.

Cuando perforas y gove a sdv->srg lvel ¿qué planeas que esta medida regrese para el nivel sdv-srg con 2-20 y 2-51?

Capture.PNG

@smpa01

Para 2-20 sería posible mostrar 727 (870 - 143), en lugar de 640

Para 2-51 sería posible mostrar 783 (870 - 87), en lugar de 640

Además, ¿llevaría eso si profundizamos hasta el nivel 3, 'sds'?

hashari_0-1614794821229.png

@hashariprueba esto

_test = 
IF (
    OR (
        OR ( ISINSCOPE ( SM[srg] ), ISINSCOPE ( SM[sds] ) ),
        ISINSCOPE ( SM[loc] )
    ),
    CALCULATE ( SUM ( CS1[metric1_subtotal] ), ALLSELECTED ( CS1 ) )
        - SUMX ( CS1, CS1[metric1_subtotal] ),
    IF (
        HASONEVALUE ( SM[sdv] ),
        VAR _1 =
            MAX ( SM[sdv] )
        VAR _2 =
            CALCULATE (
                SUMX ( CS1, CS1[metric1_subtotal] ),
                FILTER ( ALLSELECTED ( SM ), SM[sdv] <> _1 )
            )
        RETURN
            _2,
        SUMX ( CS1, CS1[metric1_subtotal] )
    )
)

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.