Last not null (nnlast)
Returns the last non-null value found in a specified column for each grouping occurrence. If you want to include null values, you can use the Last (last) operation.
How does it work in the search window?
Before being able to perform this operation, you have to group your data. Be aware that the columns used as arguments for the grouping operation will not be available to select as arguments for the aggregation operation.
After grouping the data, select Aggregation in the search window toolbar, then select the Last not null operation. You need to specify one argument:
|Last of (mandatory)||Any|
The data type of the aggregated values will be the same as the data type of the column used as argument.
demo.ecommerce.data table, we want to get the last non-null IP address value in each 5-minute period. Before aggregating the data, the table must be grouped in 5-minute intervals. Then we will perform the aggregation using the Last not null operation.
The arguments needed for the Last not null operation are:
- Last of → clientIpAddress column
Click Aggregate function and you will see the following result:
How does it work in LINQ?
Group your data using the following structure:
as... to add the new column that will show the aggregated values. This is the syntax for the Last not null operation:
See Build a query using LINQ to learn more about grouping and aggregating your data using the LINQ language.
You can copy the following LINQ script and try the example above on the
from demo.ecommerce.data group every 5m every 5m select nnlast(clientIpAddress) as last_nonnull_IP