OPS-MLTSD
Hola,
Tengo un par de columnas en mi informe PBI, dos de esas columnas en mi tabla son «Fecha de inicio del servicio» y «Fecha de finalización del servicio». Sé cómo obtener la duración en meses desde la fecha de inicio y finalización usando la función DATEDIFF. Sin embargo, hay muchos NULLS en la columna «Fecha de finalización del servicio», en esos casos, usaría la Fecha de última actualización como mi Fecha de finalización.
Tengo dos tablas en mi informe PBI: una se llama Servicio y la otra tabla se llama Última fecha de actualización. El informe no se actualiza a diario, pero se actualiza cuando se requieren datos. Me preguntaba si alguien podría decirme cómo puedo obtener la duración del servicio.
Hasta ahora, he intentado esto pero no funcionó:
Duración = IF(ESBLANCO(‘Servicio'[Service End Date]),DATEDIFF(‘Servicio'[Service Start Date],’Última fecha de actualización'[DATE],MES),(‘Servicio'[Service Start Date], ‘Servicio'[Service End Date], MESES))
¡Gracias!
jdbuchanan71
@OPS-MLTSD
Parece que quiere esto como una columna calculada en su tabla de servicios, ¿sí? Algo como esto debería funcionar.
Duration =
VAR _ServStart = Service[Service Start Date]
VAR _ServEnd = Service[Service End Date]
VAR _LastRefresh = MAX('Last Refresh Date'[Date])
VAR _EndDate = IF ( ISBLANK ( _ServEnd ), _LastRefresh, _ServEnd )
RETURN
DATEDIFF ( _ServStart, _EndDate, MONTH )
jdbuchanan71
Si desea que LastRefresh en un viernes sea la fecha de ese día, lo que significa que no retrocede al viernes anterior, sería así.
Duration =
VAR _ServStart = Service[Service Start Date]
VAR _ServEnd = Service[Service End Date]
VAR _WeekDay = WEEKDAY ( TODAY () )
VAR _LastRefresh = TODAY () - IF ( _WeekDay > 5, _WeekDay - 6, _WeekDay + 1 )
VAR _EndDate = IF ( ISBLANK ( _ServEnd ), _LastRefresh, _ServEnd )
RETURN
DATEDIFF ( _ServStart, _EndDate, MONTH )
jdbuchanan71
Eso sería así.
Duration =
VAR _ServStart = Service[Service Start Date]
VAR _ServEnd = Service[Service End Date]
VAR _LastRefresh = TODAY() - WEEKDAY( TODAY() ) - 1
VAR _EndDate = IF ( ISBLANK ( _ServEnd ), _LastRefresh, _ServEnd )
RETURN
DATEDIFF ( _ServStart, _EndDate, MONTH )
HOY () – DÍA DE LA SEMANA (HOY ()) = sábado anterior. Entonces nosotros -1 para volver a Vie.
OPS-MLTSD
En respuesta a jdbuchanan71
muchas gracias, realmente lo aprecio, ¿así que este formulario siempre ocupará el último viernes?
jdbuchanan71
En respuesta a OPS-MLTSD
Opps, mi fórmula no estaba manejando el sábado correctamente y estaba volviendo al viernes anterior al último viernes. Esto hará retroceder el sábado al día anterior (viernes) y un viernes será el viernes anterior.
Duration =
VAR _ServStart = Service[Service Start Date]
VAR _ServEnd = Service[Service End Date]
VAR _LastRefresh = TODAY() - IF ( WEEKDAY ( TODAY() ) = 7, 0, WEEKDAY ( TODAY() ) ) - 1
VAR _EndDate = IF ( ISBLANK ( _ServEnd ), _LastRefresh, _ServEnd )
RETURN
DATEDIFF ( _ServStart, _EndDate, MONTH )
Esto es lo que calcularía el VAR _LastRefresh en cada fecha de agosto:
OPS-MLTSD
En respuesta a jdbuchanan71
¡Muchas gracias! esta es información muy útil para saber 🙂
jdbuchanan71
Si lo quieres como una medida, algo como esto funcionaría.
Duration Measure =
VAR _LastRefresh =
MAX ( 'Last Refresh Date'[Date] )
RETURN
MAXX (
Service,
DATEDIFF (
Service[Service Start Date],
IF ( ISBLANK ( Service[Service End Date] ), _LastRefresh, Service[Service End Date] ),
MONTH
)
)
jdbuchanan71
@OPS-MLTSD
Parece que quiere esto como una columna calculada en su tabla de servicios, ¿sí? Algo como esto debería funcionar.
Duration =
VAR _ServStart = Service[Service Start Date]
VAR _ServEnd = Service[Service End Date]
VAR _LastRefresh = MAX('Last Refresh Date'[Date])
VAR _EndDate = IF ( ISBLANK ( _ServEnd ), _LastRefresh, _ServEnd )
RETURN
DATEDIFF ( _ServStart, _EndDate, MONTH )
OPS-MLTSD
En respuesta a jdbuchanan71
¡muchas gracias! Pregunta rápida, digamos que si End Eate es NULL, entonces quiero que la fecha de finalización sea el último viernes (por ejemplo, si hoy es el 26 de agosto, martes y quiero que la fecha de finalización sea el 20 de agosto, que fue el último viernes), ¿puedo? hacer algo como esto?
Duration =
VAR _ServStart = Service[Service Start Date]
VAR _ServEnd = Service[Service End Date]
VAR _LastRefresh = today () - weekday(today(),16)))
VAR _EndDate = IF ( ISBLANK ( _ServEnd ), _LastRefresh, _ServEnd )
RETURN
DATEDIFF ( _ServStart, _EndDate, MONTH )