You can do that in Razor.
You receive in your template an object App.Data["your_pipeline_data"] for example App.Data["Default"] depending on what you filtered, sorted, extracted in your 2sxc visual query/pipeline. You can use Linq on this object to manipulate the data and if you put this data in an enumerable type object, you can have the information you want.
An example:
@{
var termGroups = ((IEnumerable<dynamic>)AsDynamic(App.Data["Default"]))
.OrderBy(t => t.Nom) // sort terms
.GroupBy(l => l.Nom.Substring(0, 1).ToUpper()) // group by first letter
.OrderBy(s => s.Key); // ensure sorting at group-level
int groups= Enumerable.Count(termGroups);
}
is the equivalent of a GroupBy in SQL.
To manipulate all the data, do not put any Linq directive
@{
var terms = ((IEnumerable<dynamic>)AsDynamic(App.Data["Default"]));
int count = Enumerable.Count(terms);
}
After that, just use the variable in your template like that:
There are @terms items in the list.
or
There are @groups groups in the list.
Credit: the Linq code is from the 2sxc A-Z tutorial