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
Dunner2020
Post Prodigy
Post Prodigy

Suma acumulada de los meses restantes

Hola

Tengo una tabla que se parece a la siguiente:

leo_89_0-1603150744348.png

Esta tabla está conectada con una tabla de fechas que tiene el número de mes RY. Abril tiene el número de mes RY n.o 1 y Mar tiene el mes RY 12. Quiero calcular la suma acumulada del valor de esos meses que aún no han desaparecido. Debe tener el siguiente aspecto:

leo_89_1-1603150785241.png

Así que estoy creando medida algo como la siguiente:

Depuración de previsión no planeada ?

Var _CYMonth - MONTH(TODAY())
Var _RYMonth á if(_CYMonth > 3 && _CYMonth <- 12, _CYMonth - 3,_CYMonth + 9)
Var remain_month - SUM('Table'[Value])

Ser remain_month_cum a SUMX(FILTER(ALL('Table'),Max('Table'[Month Number])>- _RYMonth),remain_month)
devolución
IF(max(Dates[RY Month Number])> s_RYMonth,remain_month_cum ,BLANK() )

Sin embargo, no produce el resultado deseado. ¿Alguien podría ayudarme dónde estoy cometiendo el error?

Enlace de archivo: https://1drv.ms/u/s!AucycxZHFe9TjUOV3GfsP_bL3FcC?e=LwTupY

1 ACCEPTED SOLUTION

@leo_89 , es posible que desee probar esta medida para lograr los valores deseados,

Cumulative measure = 
VAR _CYMonth = MONTH ( TODAY () )
VAR _RYMonth = IF ( _CYMonth > 3, _CYMonth - 3, _CYMonth + 9 )
RETURN
    SUMX (
        FILTER (
            ALL ( '5y average' ),
            '5y average'[Month Number] <= MAX ( '5y average'[Month Number] )
                && '5y average'[Month Number] >= _RYMonth
        ),
        CALCULATE ( SUM ( '5y average'[Value] ) )
    )

Screenshot 2020-10-20 093712.png


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
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/

@Ashish_Mathur , He adjuntado el archivo ficticio en el post. Desafortunadamente, su cálculo no funcionó en mi archivo.

Hola

Su solución ni siquiera está remotamente cerca de lo que he sugerido. En el objeto visual, el nombre de Año y Mes debe arrastrarse desde la Tabla de calendario. Además, su medida acumulativa no está ni cerca de la mía. Por favor, estudie el archivo que he compartido con usted, con mucho cuidado.


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

Hola, @leo_89 , en cuanto a su medida, un error radica en el mal uso de la variable en esta parte, creo.

Var remain_month = SUM('Table'[Value])
Var remain_month_cum = SUMX(FILTER(ALL(Dates),Dates[RY Month Number]>=_RYMonth),remain_month)

De hecho, las variables en DAX NO SON TAN VARIABLE COMO se esperaba!

In DAX, variables are calculated within the scope in which they are written, and then the result of them is stored and used in the rest of the expression.

Es posible que desee consultar un artículo sobre este tema para obtener más detalles.

Sin un modelo de datos completo, es difícil depurar al máximo. Si adjunta un archivo ficticio con suficientes datos de maqueta, es mucho más fácil de solucionar.


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!

@CNENFRNL He incluido el archivo ficticio en el post real.

@leo_89 , es posible que desee probar esta medida para lograr los valores deseados,

Cumulative measure = 
VAR _CYMonth = MONTH ( TODAY () )
VAR _RYMonth = IF ( _CYMonth > 3, _CYMonth - 3, _CYMonth + 9 )
RETURN
    SUMX (
        FILTER (
            ALL ( '5y average' ),
            '5y average'[Month Number] <= MAX ( '5y average'[Month Number] )
                && '5y average'[Month Number] >= _RYMonth
        ),
        CALCULATE ( SUM ( '5y average'[Value] ) )
    )

Screenshot 2020-10-20 093712.png


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!

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.