Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Hola
Tengo datos de llamadas telefónicas con detalles de cada llamada.
Ahora necesito calcular la duración de cada llamada si se completael motivo.
Así que para la llamada con call_id 123 la duración es de 4 minutos.
No tengo ni idea de por dónde empezar...
Realmente me gustaría aprender cómo hacer esto.
Solved! Go to Solution.
@Dicko
Agregue el código siguiente como una nueva columna a la tabla:
Difference =
VAR __ID = Table2[call_id]
VAR __TIME = Table2[timestamp]
RETURN
IF(
Table2[reason] = "completed",
DATEDIFF(
CALCULATE(
min(Table2[timestamp]),
Table2[call_id] = __ID,
Table2[timestamp] < __TIME,
REMOVEFILTERS(Table2)
),
__TIME,
MINUTE
)
)
@Dicko
Agregue el código siguiente como una nueva columna a la tabla:
Difference =
VAR __ID = Table2[call_id]
VAR __TIME = Table2[timestamp]
RETURN
IF(
Table2[reason] = "completed",
DATEDIFF(
CALCULATE(
min(Table2[timestamp]),
Table2[call_id] = __ID,
Table2[timestamp] < __TIME,
REMOVEFILTERS(Table2)
),
__TIME,
MINUTE
)
)
¡Gracias! Aprendí algo nuevo 🙂
Hola @Dicko ! Prueba esto, podría funcionar:
duration =
var _id = SELECTEDVALUE( Table[call_id] )
var _reason = SELECTEDVALUE( Table[reason] )
var _startcall = CALCULATE( MIN( Table[timestamp] ), FILTER( Table, Table[status] = "created" && Table[call_id] = _id ))
var _endcall = CALCULATE( MAX( Table[timestamp] ), FILTER( Table, Table[status] = "ended" && Table[call_id] = _id ))
return
IF( _reason = "completed",
DATEDIFF( _startcall, _endcall, MINUTE)
)
¡Espero que esta respuesta resuelva su problema! Si necesita ayuda adicional, por favor etiquéteme en su respuesta.
Si mi respuesta le proporcionó una solución, ¡márquela como una solución ✔️ o dele un kudoe 👍
¡Gracias!
Saludos
Gonçalo Geraldes
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.