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

Promedio de Power BI entre diferentes fechas

¡Hola!

Quiero calcular el tiempo promedio entre las fechas. Los datos se ven así:

PasoFecha y hora
214.11.2022 13:02:56
414.11.2022 13:05:15
214.11.2022 13:11:23
414.11.2022 13:13:38
214.11.2022 13:24:03
414.11.2022 13:26:21
215.11.2022 12:16:58
415.11.2022 12:19:28

Necesito obtener un tiempo promedio entre todos los pasos número 4 y stpes número 2.

14.11.2022 13:05:15 - 14.11.2022 13:02:56 = 00:02:19

14.11.2022 13:13:38 - 14.11.2022 13:11:23 = 00:02:15

14.11.2022 13:26:21 - 14.11.2022 13:24:03 = 00:02:18

15.11.2022 12:19:28 - 15.11.2022 12:16:58 = 00:02:30

El promedio entre los cuatro es igual a 00: 02:20

Cuando uso la fórmula medida = CALCULATE(SUM(Logging[CreatedAt]),Logging[Step] = 4) - CALCULATE(SUM(Logging[CreatedAt]),Logging[Step] = 2) calcula el total de las cuatro filas.

El resultado de la fórmula anterior 30.12.1899 0:09:22

(Por cierto, ¿cómo deshacerse de este extraño resultado de fecha 30.12.1899?)

Si utilizo la fórmula measure = AVERAGEX(Logging, CALCULATETABLE(VALUES(Logging[CreatedAt]), FILTER(Logging, Logging[Step] = 4)) - CALCULATETABLE(VALUES(Logging[CreatedAt]), FILTER(Logging, Logging[Step] = 4))) no entrega nada.

2 REPLIES 2
Syndicate_Admin
Administrator
Administrator

Hi, @bombom

Para sus necesidades, deberá convertir la diferencia a "segundos", tomar el promedio y convertir el resultado al formato de tiempo.

Por favor, pruebe la fórmula de medida como:

EndAt = 
IF (
    MAX ( Logging[Step] ) = 2,
    CALCULATE (
        MIN ( Logging[CreatedAt] ),
        FILTER ( ALL ( Logging ), Logging[CreatedAt] > MAX ( Logging[CreatedAt] ) )
    ),
    BLANK ()
)
diff(second) = DATEDIFF(MAX(Logging[CreatedAt]),[EndAt],SECOND)
Average = AVERAGEX(Logging,[diff(second)])
Result1 = 
IF (
    [Average] = BLANK (),
    BLANK (),
    TIME ( 0, 0, FLOOR ( 'Souktion1'[Average], 1 ) )
)

Si el resultado total es 30.12.1899 0:09:22, solo necesita cambiar el formato de su medida.

veasonfmsft_0-1670220033856.png

Resultado:

veasonfmsft_1-1670220283849.png

Referencia:

HORA

PISO

Saludos
Equipo de Apoyo a la Comunidad _ Eason

Syndicate_Admin
Administrator
Administrator

@bombom , Pruebe una medida como

AVERAGEX(Tabla,
var _max = maxx(filter(Table, Table[Datetime] < before([Datetime]) && [Step] =2),[Datetime])
devolución
if([Step] =4,datediff(_max,[Datetime],second) ,blank())
)

o

tiempo(0,0,0) + PROMEDIOX(Tabla,
var _max = maxx(filter(Table, Table[Datetime] < before([Datetime]) && [Step] =2),[Datetime])
devolución
if([Step] =4,datediff(_max,[Datetime],second) ,blank())
)/(3600*24)

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.