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
Anonymous
Not applicable

Calcular la suma de una columna, dependiendo de la jerarquía

Hola expertos,

Me he metido en este problema: Tener esta Matriz. Teniendo un código de hierearchy->Type->Status->Course->Product, me gustaría calcular la Suma de Población , dividida por el número de los registros, dependiendo del nivel de jerarquía:

SS1.png

En este caso, la medida "Pop x grade" está haciendo bien:

Pop x Grade = SUM('Fact'[Population]) / 
COUNTROWS('Fact')

Sin embargo, si sumo dos niveles de la jerarquía, me gustaría sumar "Pop x Grade"

Screenshot_1.png

El resultado de la victoria, debe ser la suma de (81 +78 +77+78+40+76+77+76+79+79)

¿Cómo puedo crear una medida de este tipo? Estoy tratando de usar las funciones "X", pero estoy atascado en él.

¿Alguna idea?

Puede encontrar un ejemplo de PBIX aquí:

Gracias

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

Hola, @danimelv , pls probar medida

Segmentation = 
SWITCH (
    TRUE (),
    ISINSCOPE ( 'Fact'[Product] ) || ISINSCOPE ( 'Fact'[Course] ), [Pop x Grade],
    ISINSCOPE ( 'Fact'[Probability] ),
        SUMX (
            VALUES ( 'Fact'[Course] ),
            [Pop x Grade]
        ),
    ISINSCOPE ( 'Fact'[Type] ), "Type", // change to any calculation at your own will
    "Code" // change to any calculation at your own will
)

En cuanto al nivel "Tipo" o "Código", puede utilizar cualquier otro cálculo a su propia voluntad.


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

6 REPLIES 6
Syndicate_Admin
Administrator
Administrator

Hola @CNENFRNL !
¿Cómo puedo cambiar la línea a nivel de "Tipo" y "Código" si quiero que los resultados en "Tipo" sean iguales a la suma de "Probabilidad" definida en la cláusula ISINSCOPE anterior? Con la misma lógica, me gustaría ver resultados a nivel de "Código" igual suma de "Tipo". He intentado esto, pero no mostró la cantidad total correcta en el nivel "Tipo" y "Código".

Segmentation = 
SWITCH (
    TRUE (),
    ISINSCOPE ( 'Fact'[Product] ) || ISINSCOPE ( 'Fact'[Course] ), [Pop x Grade],
    ISINSCOPE ( 'Fact'[Probability] ),
        SUMX (
            VALUES ( 'Fact'[Course] ),
            [Pop x Grade]
        ),
    ISINSCOPE ( 'Fact'[Type] ),
        SUMX (
            VALUES ( 'Fact'[Probability] ),
            [Pop x Grade]
        ),
    ISINSCOPE ( 'Fact'[Code] ),
        SUMX (
            VALUES ( 'Fact'[Type] ),
            [Pop x Grade]
        )
)

¡Gracias de antemano!

Syndicate_Admin
Administrator
Administrator

¡Hola!
¿Cómo puedo cambiar la línea a nivel de "Tipo" y "Código" si quiero que los resultados en "Tipo" sean iguales a la suma de "Probabilidad" definida en la cláusula ISINSCOPE anterior? Con la misma lógica, me gustaría ver resultados a nivel de "Código" igual suma de "Tipo". He intentado esto, pero no mostró la cantidad total correcta en el nivel "Tipo" y "Código".

Segmentation = 
SWITCH (
    TRUE (),
    ISINSCOPE ( 'Fact'[Product] ) || ISINSCOPE ( 'Fact'[Course] ), [Pop x Grade],
    ISINSCOPE ( 'Fact'[Probability] ),
        SUMX (
            VALUES ( 'Fact'[Course] ),
            [Pop x Grade]
        ),
    ISINSCOPE ( 'Fact'[Type] ),
        SUMX (
            VALUES ( 'Fact'[Probability] ),
            [Pop x Grade]
        ),
    ISINSCOPE ( 'Fact'[Code] ),
        SUMX (
            VALUES ( 'Fact'[Type] ),
            [Pop x Grade]
        )
)

¡Gracias de antemano!

CNENFRNL
Community Champion
Community Champion

Hola, @danimelv , pls probar medida

Segmentation = 
SWITCH (
    TRUE (),
    ISINSCOPE ( 'Fact'[Product] ) || ISINSCOPE ( 'Fact'[Course] ), [Pop x Grade],
    ISINSCOPE ( 'Fact'[Probability] ),
        SUMX (
            VALUES ( 'Fact'[Course] ),
            [Pop x Grade]
        ),
    ISINSCOPE ( 'Fact'[Type] ), "Type", // change to any calculation at your own will
    "Code" // change to any calculation at your own will
)

En cuanto al nivel "Tipo" o "Código", puede utilizar cualquier otro cálculo a su propia voluntad.


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

amitchandak
Super User
Super User

@danimelv , Dependiendo de la jerarquía si desea cambiar los totales puede nosotros isinscope

ejemplo: Cálculo diferente a un nivel diferente

Medidas ?
SWITCH (
Verdad
ISINSCOPE ( 'Tabla'[Estado] ), [Costing],
ISINSCOPE ( 'Tabla'[Ciudad] ), [Costing1],
blank()
)

hacer referencia para más detalles : https://www.kasperonbi.com/use-isinscope-to-get-the-right-hierarchy-level-in-dax/

Ajinkya369
Resolver III
Resolver III

Hey @danimelv ,

Por favor, siga esta entrada de blog:

https://www.daxpatterns.com/parent-child-hierarchies/

Si su problema se resuelve, por favor acepte esta respuesta como una solución.

Gracias

Ajinkya

Análisis de datos maestros -

@Ajinkya369 - He creado MM3TR&R para este propósito, teniendo diferentes agregaciones/cálculos en diferentes niveles de un hiearchy.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Matrix-Measure-Total-Triple-Threat-Rock-amp-...


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.