I hope you can help me. That problem makes me crazy…
Given a table, which shows the booked services of devices. There is a new entry per device, if the booked services changed.
let devices=datatable(device:string, timestamp:datetime, bookedServices:dynamic) [
"device-1", datetime(2024-06-11), dynamic(["service1", "service2"]),
"device-2", datetime(2024-06-11), dynamic(["service1", "service2"]),
"device-1", datetime(2024-06-13), dynamic(["service2"]),
"device-3", datetime(2024-06-14), dynamic(["service3"]),
"device-1", datetime(2024-06-16), dynamic([]),
"device-1", datetime(2024-06-19), dynamic(["service1", "service2"])
];
What I would like to get is a table like this:
Service | Timestamp | NumberOfDevices |
---|---|---|
service1 | 2024-06-11 | 2 |
service2 | 2024-06-11 | 2 |
service1 | 2024-06-13 | 1 |
service3 | 2024-06-14 | 1 |
service2 | 2024-06-16 | 1 |
service1 | 2024-06-19 | 2 |
service2 | 2024-06-19 | 2 |
I could get the currently booked services simply with query like this.
devices
| summarize arg_max(timestamp,*) by device
| mv-expand bookedServices to typeof(string)
| summarize count() by bookedServices
But I have no idea, how to get a history table like shown above.
Any help appreciated!