Prerequisite
Complete the steps in Create a basic statistic.Creating a multi-column statistic definition
To begin with this example, we need to create a more complex statistic definition than the one we had before. We’re going to define multiple columns to map the key aspects of the long shot: distances and caliber. The following example shows how to create the statistic definition using the C# SDK.Columns parameter, which allows multiple definitions of StatisticColumn so
that statistic could have multiple values. The only exception is when we use the aggregation of Sum. Also, the maximum number of columns allowed is 5.
Adding data to a statistic
Now that we have our statistic created, we’re going to add data. The main difference from our previous tutorial on this subject is that now we need to add two different values. The following example shows how to add data to our statistic using the C# SDK.Scores parameter within the statistic that is going to be added. In the code example,
we see two different values, which are all them strings, but it’s just an input definition within the statistic. These values
are handled as numbers. The length of the list of scores should always match with the number of columns of the statistic
definition.
Retrieving data from a statistic
Now we’re going to learn a way to query multiple entities and get all of the statistics related to each of them. The following example shows how to add data to our statistic using the C# SDK.Tie-breaking
When we have a multi-column statistic definition, we could come across a scenario that needs tie-breaking. The way this mechanism works is that follows the way in which columns were added. Whenever a new value comes in, the system checks if it meets the criteria of the aggregation for the first column. In case the value is the same, then it goes and checks the criteria for the second column. This behavior continues for the following columns. For example, we can have a statistic with three columns:- First column has Min Aggregation.
- Second column has Max Aggregation.
- Third column has Last Aggregation.
Conclusion
In this tutorial, we learned how to do the following operations:- Create a multi-column statistic
- Query for statistics
- Understand how tie-breaking works.
