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

Ponerse en marcha 3 meses promedio

Hola a todos,

Estoy teniendo algunos problemas para conseguir un promedio de 3 meses para que funcione correctamente. He probado 5 fórmulas diferentes y devuelven 0 o en blanco. Tengo una tabla de fechas con la primera fecha como 01/01/1989 y una fecha de finalización del 31/12/2027. Mi tabla de datos tiene fechas EndOfMonth, que comienzan el 31/01/2019 y terminan con el 31/08/2022. Sumé los datos a un total mensual en SQL, para ahorrar tiempo al cargar todas las filas.

Aquí hay un ejemplo de la última fórmula que traté de usar:

nleuck_101_0-1660064769899.png

Cualquier ayuda sería muy apreciada.

1 REPLY 1
Syndicate_Admin
Administrator
Administrator

@nleuck_101,

¿Has probado este patrón?

https://www.daxpatterns.com/standard-time-related-calculations/#code61

Sales AVG 3M :=
VAR Period3M =
    CALCULATETABLE (
        DATESINPERIOD (
            'Date'[Date],
            MAX ( 'Date'[Date] ),
            -3,
            MONTH
        ),
        'Date'[DateWithSales] = TRUE
    )
VAR FirstDayWithData =
    CALCULATE (
        MIN ( Sales[Order Date] ),
        REMOVEFILTERS ()
    )
VAR FirstDayInPeriod =
    MINX ( Period3M, 'Date'[Date] )
VAR Result =
    IF (
        FirstDayWithData <= FirstDayInPeriod,
        AVERAGEX (
            Period3M,
            [Sales Amount]
        )
    )
RETURN
    Result

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.