Count Distinct
Count the number of unique values for a given aggregation.
First, create a new mapping group by or group by. Order by the tag you want to count. Choose "Distinct Consec." for your tag. This only counts distinct values if they are consecutive, which is why you need to order by your tag.
Next, create a java computing with your new tag .distcons as _str1
//Ignore lines with no value </br>
if (_str1.length()==0) return "";
//Count the number of pipes "|" + 1 </br>
return _str1.chars().filter(c -> c == '|').count() + 1;
Note that you should pick small aggregations and use tags with few characters. Otherwise this could be slow.
Manual ID
To keep only a fixed number of lines in Braincube - To be coupled with a Java Filter in MX table
if (_doJava.get("_str1",-1).equals(""))
return 1.0;
double previous = Str.ToDouble(_doJava.get("_str1",-1));
if (previous >= 5000000.0)
return 1.0;
return previous + 1.0;
Reverse Counter - Count the last X products before an event

//First java : ReverseTime
//String1 : Your Time index
//String2 : Number of the product (index)
* Description : Variable for sorting in reverse order on Time_NumPlaque
if(_str1.equals("")) return "";
double bigNum = Str.ToDouble(Str.Left(_str1,8) + Str.Right(_str1,6) + Str.Right(_str2,1));
return 9999999999999999. - bigNum;
//Second Java : With Order : ReverseTime
//String1 : ReverseTime
//String2 : Java itself
* Description : Returns Last Products from 1 to 10 for the 10 last "plaques"
String lastResult = _doJava.get("_str2", -1);
if (_str1.equals("")) {
return "";
} else if (_doJava.get("_str1", -1).equals("")) {
return "1";
} else if (lastResult.equals("1")) {
return 2;
} else if (lastResult.equals("")){ //in case multiple lines are added, we need to "reset" the remaining lines that go below 10.
return "";
} else if (Str.ToIntOrZero(lastResult)<10) {
return Str.ToIntOrZero(lastResult) +1;
} else {
return "";
return "";