Perform basic calculation on data

<< Click to Display Table of Contents >>

Navigation:  Building Streaming Applications > Tutorial 1: Introduction to StreamLab >

Perform basic calculation on data

Previous pageReturn to chapter overviewNext page

Now that you have formatted the imported data, you are ready to perform a calculation on the data. A calculation can be as simple as multiplying the value of a column by two, or pretty much as complex as you need.

Using StreamLab Analytics

Click on the Analytics tab at the top of ScreenLab. Note the group of commands listed:

sbur_sl_analytics

Analytics let you apply a number of different analytics to the Output view in StreamLab. Some of these produce new columns, and others change selected columns themselves.

Bucketize

This command lets you create quick "buckets" of data for a particular column, including COUNT, SUM, and AVERAGE.

Calculate

This command lets you perform an arithmetical calculation on a column, such as adding 2000 to the column or dividing the column in 2. Selected columns must have numerical values, such as DOUBLE.

Categorize

This command lets you take a continuous value, such as a bus speed, and replace it with strings such as "fast", "medium", or "slow" by applying conditions to the column.

Running Average

This command lets you create a new column that is a running average of another column over a given window of time.

Time Sort

This command uses a sliding time-based window of incoming rows to reorder those rows by the selected column or by ROWTIME in order to address time synchronization problems with data.

Window

This command lets you perform a windowed aggregation on a selected column. The command produces a new column with the result of the operation.

Partition Window

This command lets you partition rows into groups using the columns in a particular column.

GroupRank

This command lets you group rows by the values in one column (group by) and then rank the rows within that group according to another column (rank by) across a window defined by you.

Here, we're going to apply a simple calculation to the speed column that identifies buses going faster than 45 kilometers an hour.

To do so, you use an analytic called Categories.

1.Click the Categorize tab.
2.Now, scroll right and select the speed column
3.Enter normal for the default category and speeding for the next category. With the speeding category, select is greater than or equal to, then enter 45. This tells StreamLab "divide the column speeders into two categories: normal for everything not greater than 45, and speeding for everything greater than 45."
4.After entering information for the category, click the + button in the Suggestions window to add the category to the Script.

guide category speeding

When it refreshes, scroll right to see that the speed column now lists "speeding" and "normal" instead of numerical speeds.

You are now ready to display the formatted and analyzed data in a dashboard.