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

Encuentra la tendencia actual en series temporales

Hola

Tengo una tabla de series temporales (escasa) y quiero calcular la tendencia actual basada sólo en los últimos 3 valores.

Creo que la pendiente de la línea de tendencia (Regresión lineal) podría considerarse como la tendencia actual.

He encontrado código que describe el cálculo de regresión lineal DAX, pero se basa en todos los valores anteriores.

Sé que puede ser una tontería, pero estoy amontonada.

¿Puede sugerir una solución alternativa?

Gracias de antemano.

identificaciónFecha y hora valor
11/1/2021 8:00:25 0.24
21/1/2021 9:45:10 0.24
31/1/2021 14:35:38 0.29
42/1/2021 11:12:00 0.28
52/1/2021 19:43:29 0.27
63/1/2021 7:17:12 0.26

1 ACCEPTED SOLUTION
Syndicate_Admin
Administrator
Administrator

Hey @KyriakosT ,

Creé esta medida simple:

just the average value = 
CALCULATE(
    AVERAGE( 'Table'[Value] )
)

y este más complejo, aquí utilizo TOPN para encontrar los 3 valores anteriores

the average of the last 3 datetimes = 
var __datetime = MAX( 'Table'[Datetime] )
return
CALCULATE(
    [just the average value]
    , TOPN(
        3
        , FILTER( ALL('Table'[Datetime] ) , 'Table'[Datetime] < __datetime )
        , 'Table'[Datetime]
        , DESC
    )
    , ALL('Table'[ID] , 'Table'[Value])
)

parece que la segunda medida crea lo que está buscando

image.png

Con suerte, esto proporciona lo que está buscando.

saludos

gato

View solution in original post

1 REPLY 1
Syndicate_Admin
Administrator
Administrator

Hey @KyriakosT ,

Creé esta medida simple:

just the average value = 
CALCULATE(
    AVERAGE( 'Table'[Value] )
)

y este más complejo, aquí utilizo TOPN para encontrar los 3 valores anteriores

the average of the last 3 datetimes = 
var __datetime = MAX( 'Table'[Datetime] )
return
CALCULATE(
    [just the average value]
    , TOPN(
        3
        , FILTER( ALL('Table'[Datetime] ) , 'Table'[Datetime] < __datetime )
        , 'Table'[Datetime]
        , DESC
    )
    , ALL('Table'[ID] , 'Table'[Value])
)

parece que la segunda medida crea lo que está buscando

image.png

Con suerte, esto proporciona lo que está buscando.

saludos

gato

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.