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 R12M para CADA MES, como una medida

Hola a todos,

Estoy tratando de encontrar una manera de calcular la suma R12M para cada uno de los meses en la tabla, como una sola medida. Me gustaría que se pareciera más o menos a esto:

Mes:Enero de 2019Febrero 2019MarzoAbrilMayoJunioJulioAgostoSieteOctubreNoviembreDiciembreEne 2020Febrero 2020Marzo de 2020
Valor:123451234512345
R12M: 33353739
(suma marzo 2019 - feb 2020)

(suma de abril 2019-marzo 2020)

Encontré una manera de calcular R12M este año y el año pasado, usando las fórmulas a continuación:

RTM (TY) - CALCULATE([Suma total de ventas]; DATESINPERIOD('Calendar'[Fecha]; MAX('Calendario'[Fecha]); -12; MES))

RTM (LY) - CALCULATE([Suma total de ventas]; DATEADD(DATESINPERIOD('Calendar'[Fecha]; MAX('Calendario'[Fecha]); -12; MES); -1; Año))

Sin embargo, con este enfoque tendría que crear una medida independiente para cada mes, y no es lo que quiero.

Le agradecería cualquier ayuda 🙂

5 REPLIES 5
parry2k
Super User
Super User

@aleksaste no necesita crear dos medidas, poner año y mes a partir de la tabla de calendario y una medida funcionaría?

Me gustaría elogiossi mi solución me ayudó.👉Si puedes pasar tiempo publicando la pregunta, también puedes hacer esfuerzos para darle a Kudos quien haya ayudado a resolver tu problema. ¡Es una muestra de agradecimiento!



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

¿Podría mostrarme cómo sería una medida así?

@aleksaste debería funcionar su medida RTM (TY)? Si no, comparta lo que no está funcionando.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Hola, no era consciente de que simplemente puedo trazarlo en una línea de tiempo y se calculará. Por alguna razón estaba convencido de que tengo que usar algún tipo de variable para seleccionar un mes específico, porque pensé que siempre tomará toda la tabla de calendario (sin filtrar) como base. ¡Tan fácil! Gracias.

v-gizhi-msft
Community Support
Community Support

Hola

Aquí está mi tabla de prueba:

6.PNG

Por favor, siga estos pasos:

1)Crear una nueva tabla de segmentación de datos por Introducir datos:

8.PNG

2)Pruebe esta medida:

Measure = 
VAR a =
    IF (
        MAX ( 'Table'[Date] ) >= DATE ( 2019, 12, 1 ),
        CALCULATE (
            SUM ( 'Table'[Value] ),
            FILTER (
                ALLSELECTED ( 'Table' ),
                'Table'[Date] <= MAX ( 'Table'[Date] )
                    && 'Table'[Date]
                        >= IF (
                            MONTH ( MAX ( 'Table'[Date] ) ) = 12,
                            DATE ( YEAR ( MAX ( 'Table'[Date] ) ) - 1, 1, 1 ),
                            DATE ( YEAR ( MAX ( 'Table'[Date] ) ) - 1, MONTH ( MAX ( 'Table'[Date] ) ) + 1, 1 )
                        )
            )
        )
    )
RETURN
    SWITCH (
        SELECTEDVALUE ( 'Table 2'[Month] ),
        "Value", SUM ( 'Table'[Value] ),
        "R12M", a
    )

3)El resultado muestra:

10.PNG

Vea mi archivo pbix adjunto.

Saludos

Giotto

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.