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

Diferencia y grupo para la fecha

¡Hola! Necesito ayuda con una función. ¿Cómo puedo obtener la diferencia entre el FinishDate anterior y el StartDate por ID de la tabla de datos a continuación? Puede ser en M o DAX. El resultado sería en horas.

Imagem1.png

4 REPLIES 4
Syndicate_Admin
Administrator
Administrator

compareDate =
Dónde startdate = Standby[Fecha de inicio]
Dónde maxfinishdate =
CALCULAR (
..MAX ( Standby[FinishDate] ),
FILTRO ( Todo ( Standby ), Standby[finishDate] < startdate,allexcept(Stanby,Stanby[ID])
)
Dónde resultado =
DATEDIFF ( startdate, maxfinishdate , DAY )
DEVOLUCIÓN
resultado

Lo sentimos, allexcept no funciona en este código dax

demandar esto en su lugar

compareDate =
Dónde fecha de inicio = Espera[Fecha de inicio]
Dónde searchid = Espera[ID]
Dónde maxfinishdate =
CALCULAR (
..MAX ( Espera[Fecha de finalización] ),
FILTRO ( Todo ( Espera ), Espera[Fecha de finalización] < fecha de inicio&&Espera[ID]=searchid)
)
Dónde resultado =
DATEDIFF ( fecha de inicio, maxfinishdate , Día )
DEVOLUCIÓN
resultado
Syndicate_Admin
Administrator
Administrator

Hola, por favor, encuentre el código:

compareDate =
Dónde startdate = Standby[Fecha de inicio]
Dónde maxfinishdate =
CALCULAR (
..MAX ( Standby[FinishDate] ),
FILTRO ( Todo ( Standby ), Standby[finishDate] < startdate )
)
Dónde resultado =
DATEDIFF ( startdate, maxfinishdate , DAY )
DEVOLUCIÓN
resultado

¡Funcionó para las fechas! Pero creo que hay que crear una variable para agrupar por ID antes de marcar la diferencia entre fechas. Agrupar fechas por a, b, c, d. Eso es lo que no soy capaz de hacer. Y el resultado de tu función es ser un número negativo

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.

Top Solution Authors