24 Nov 2025
09:17 PM
- last edited on
25 Nov 2025
10:33 AM
by
MaciejNeumann
Hello i have this code
| fieldsAdd FechaTs = toTimestamp(Fecha)
| summarize
FechaInicial = min(FechaTs),
FechaFinal = max(FechaTs),
by: { Identificador }
| fieldsAdd
DiffMs = toLong(FechaFinal - FechaInicial),
DiffSec = toLong((FechaFinal - FechaInicial) / 1000)
| sort DiffMs desc
Solved! Go to Solution.
24 Nov 2025 09:37 PM
Hi @marusla 🙂
You can calculate the difference directly during the pipeline by adding a new field that performs the subtraction between the two values you already computed.
For example, after defining DiffMs and DiffSec, simply add:
| fieldsAdd Difference = DiffMs - DiffSecSo your full query would look like:
| fieldsAdd FechaTs = toTimestamp(Fecha) | summarize FechaInicial = min(FechaTs), FechaFinal = max(FechaTs), by: { Identificador } | fieldsAdd DiffMs = toLong(FechaFinal - FechaInicial), DiffSec = toLong((FechaFinal - FechaInicial) / 1000) | fieldsAdd Difference = DiffMs - DiffSec | sort DiffMs descThis adds a new column with the subtraction result without modifying the rest of your logic.
Best regards,
24 Nov 2025 09:45 PM
i use the commands, but stil have the problem
25 Nov 2025 01:42 AM
Thanks, i have i have to use other convertion
| summarize FechaInicial = min(Fecha), FechaFinal = max(Fecha), by: { Identificador}
| fieldsAdd Duracion = (totimestamp(FechaFinal) - totimestamp(FechaInicial))