Insert a Manage fields transformation before Group by and convert time to datetime, because MAX() returns the same data type as its input expression. ^1^
No-code correction
- Open the eventstream and select Edit.
- On the connection immediately before Group by, select Transform events or add destination → Manage fields.
- Open the transformation with the pencil icon.
- Add the existing
time field and change its data type from string to datetime. Manage fields supports changing a field’s data type. ^2^
- Save the transformation and inspect its preview:
-
time should now appear as a datetime.
- Invalid timestamp text should be corrected at the source or normalized before aggregation.
- Connect Manage fields to Group by.
- In Group by, configure:
- The required grouping dimensions.
- The required time window.
-
MAX(time) under aggregations, with an output name such as MaxTime.
- Preview the Group by output and confirm
MaxTime is datetime before publishing.
Do not also place time in the list of grouping dimensions unless events with identical timestamps are intentionally meant to form separate groups. Group By returns one summary row for each combination of grouping values and window. ^3^
TIMESTAMP BY accepting ISO 8601 strings does not mean that every reference to that payload field becomes datetime. It controls the event’s application timestamp; MAX(time) still operates on the payload field’s inferred or declared type. ^4^
SQL operator fallback
If the no-code preview already identifies the input as datetime but Group by still emits a string, replace that transformation with a SQL operator and cast explicitly. Add it through Transform events → SQL, then test before saving. SQL operators use Azure Stream Analytics query semantics. ^5^
SELECT
DeviceId,
MAX(TRY_CAST([time] AS DATETIME)) AS MaxTime
INTO
output
FROM
input
GROUP BY
DeviceId,
TumblingWindow(minute, 5)
Replace DeviceId, the window, and the input/output aliases with those from the eventstream. Use TRY_CAST while diagnosing malformed values; values that cannot be converted become null rather than failing the entire conversion.
After selecting Test query, verify that:
-
MaxTime is datetime.
- The expected records contribute to each window.
- No unexpected nulls indicate malformed timestamp strings.
If the source preview, Manage fields output, and Group by input all show datetime but only the Group by output changes to string, capture those three schema previews and the transformation configuration when opening a Fabric support case. That would contradict the documented MAX() return-type behavior and is not resolved by further source-side conversion.
References
- MAX
- Route data streams based on content in Microsoft Fabric eventstreams
- GROUP BY
- TIMESTAMP BY
- Process events by using a SQL operator