Kusto Lightning Fact 5: make-series
- azurecoder
- Jul 26, 2020
- 2 min read
A key capability of Kusto Query Language and Azure Data Explorer is the ability to make time series. This is the start of a 3-series set of posts starting with the make-series operator. We'll continue working with the sales dataset and define the overall scope of the query we're trying to build here.
let series = sales
| where getyear(Order_Date) == 2010 and getmonth(Order_Date) == 1
| summarize UnitsSold = sum(Units_Sold) by Region, Timestamp = Order_Date
| order by Timestamp asc;
let min_t = toscalar(series | summarize min(Timestamp));
let max_t = toscalar(series | summarize max(Timestamp));
series
| make-series NumSold=sum(UnitsSold) default=0 on Timestamp in range(min_t, max_t, 1d) by Region
| render timechart
Firstly we create a variable called series which looks at all of the Units sold in January 2010 only segmented by Region.
We also set 2 more variables min_t which contains the first Timestamp value (1st January 2010) and max_t which contains the last Timestamp value (31st January 2010).
Two more functions that we've introduced are the toscalar function which converts the variables into a single value and the range function. Similar to the Python keyword this produces a range which we'll use between the max and min Order_Date. It's also interpolated so will fill in the gaps if there are zero units sold on that day.
To do this we'll look at the time-series function. This function will create a variable called NumSold which will aggregate the number sold by Region by Day and if there are no sales then it will default to zero. In our case we want to know if there are no sales for that particular day but in other cases we might want to fill in the blanks in different ways.
In KQL we can use the following functions to do this:
series_fill_forward() - uses the previous value to fill the current one
series_fill_backwards() - uses the next value to fill the previous missing value
series_fill_constant() - uses a constant value for missing values - as per example is default in shorthand
series_fill_linear() - uses a linear interpolation function to fill in the missing values
The end result looks like this.

It's worth trying the following query which we'll use in the next couple of Lightning Fact pieces which is shown below.
let series = sales
| where getyear(Order_Date) == 2010 and (getmonth(Order_Date) == 1
or getmonth(Order_Date) == 2 or getmonth(Order_Date) == 3) and (Country == "United Kingdom" or Country == "Canada" or Country == "France")
| summarize UnitsSold = sum(Units_Sold) by Country, Timestamp = Order_Date
| order by Timestamp asc;
let min_t = toscalar(series | summarize min(Timestamp));
let max_t = toscalar(series | summarize max(Timestamp));
series
| make-series NumSold=sum(UnitsSold) default=0 on Timestamp in range(min_t, max_t, 1d) by Country
| render timechart
The graph that this renders show the interpolation of the values at 0 where they don't exist which is what we want.

Hotly anticipated, the collector link response when this reference was released was mixed. But, over the past decade, this rare and very precious take on the Daytona link has proven itself to be something of an insider's reference. link With its collectability only growing by the year, this special anniversary model leans into its ice dial and platinum construction to offer a Daytona like no other.
In the photo at the top (and above), you'll also notice link another version of the KV20i that I don't believe has been shared before. Kari himself pulled it out of the case at link the Académie Horlogère des Créateurs Indépendants (AHCI) show in the midst of Watches & Wonders and put it on the table in front of me. In addition to the "petrol blue" ring and 3N gold-grained finishing, the case is made of tantalum and is a unique link piece.
As I mature in my watch collecting journey, I tend to gravitate toward more interesting and funky designs. This Super-Dive is link a good combination of funky and link conventional, rolled into one. It's got the dual crown case with the internal rotating bezel and interesting hour markers so it has a lot going on, but it's done in a way that just link works. As vintage watches go, finding something bigger than 40mm is not always easy and this Super-Dive checks that box. Check out all the details here!
Lugrin's patents gave Waltham an option for inexpensive, reliable, and easily-installed chronographs. They finished stem-wind 14-size movements, mainly 1874 and 1884 link models with ¾ plates similar to Swiss ebauché movements, at their factory in Massachusetts and shipped them to their sales representatives Robbins link & Appleton in New York where, in addition to placing other watches in high-end gold cases, the company worked with Lugrin and Aubert to modify these movements to add link complications.
Brand: BreguetModel: Classique Tourbillon Extra-Plat Squelette 5395Reference Number: link 5395BR/1S/9WU Diameter: 41mmThickness: link 7.70mmCase Material: rose gold or platinumDial Color: transparent link sapphireWater Resistance: 30 metersStrap/Bracelet: alligator leather with folding buckle in rose gold or platinum