DP-700 · Question #50
You have a Fabric eventhouse that contains an KQL database. The database contains a table named TaxiData. The following is a sample of the data in TaxiData. VendorID tpep_pickup_datetime…
This question tests knowledge of KQL (Kusto Query Language) window functions and partitioning - specifically row_cumsum() for running totals partitioned by a grouping column, and first_value() combined with bin() for extracting the first occurrence per time bucket per partition.
Question
- One of the queries must partition RunningTotalAmount by VendorID.
- The other query must create a column named FirstPickupDateTime that shows the first value of each hour from tpep_pickup_datetime partitioned by payment_type. How should you complete each query? To answer, drag the appropriate values the correct position.
Explanation
This question tests knowledge of KQL (Kusto Query Language) window functions and partitioning - specifically row_cumsum() for running totals partitioned by a grouping column, and first_value() combined with bin() for extracting the first occurrence per time bucket per partition.
Approach. For the RunningTotalAmount query, the correct approach uses row_cumsum(total_amount, VendorID != prev(VendorID)) after sorting by VendorID and tpep_pickup_datetime - the second argument acts as a restart condition so the cumulative sum resets at each new VendorID boundary. For the FirstPickupDateTime query, the correct approach uses bin(tpep_pickup_datetime, 1h) to bucket timestamps into hourly slots, then either summarize first_value(tpep_pickup_datetime) by payment_type, bin(tpep_pickup_datetime, 1h) or arg_min(tpep_pickup_datetime, *) grouped by payment_type and the hourly bin - this extracts the earliest timestamp within each hour for each payment type. Both queries rely on KQL's ability to partition analytic computations either through the partition by operator or through sort-dependent scalar functions like row_cumsum() and first_value().
Concept tested. KQL window/analytic functions in Microsoft Fabric Eventhouse: row_cumsum() with a restart predicate for partitioned running totals, and first_value() or arg_min() combined with bin() for time-bucketed first-occurrence aggregation, both partitioned by a categorical column.
Reference. https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query/row-cumsum-function
Topics
Community Discussion
No community discussion yet for this question.