Hello Dave,
You can check your Ticket ID: 1539825 where I sent you the project in VB.NET. I am also attaching it here for reference.
I hope that it will work for your project.
Regards,
Hristo
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
per below.. I can't seem to convert this to vb.net properly.
this.provider.AggregateDescriptions.Add(new PropertyAggregateDescription()
{
PropertyName = "Product",
AggregateFunction = new DistinctCountAggregateFunction()
});
Thank you Hristo, would you happen to have a vb.net version of this?
Hello,
This is a sample implementation of a the DistinctCountAggregate:
public sealed class DistinctCountAggregateFunction : AggregateFunction
{
public override string DisplayName
{
get
{
return "Distinct Count";
}
}
protected override AggregateValue CreateAggregate(IAggregateContext context)
{
return new DistinctCountAggregate();
}
public override string GetStringFormat(Type dataType, string format)
{
return "G";
}
public override int GetHashCode()
{
return 1;
}
public override bool Equals(object obj)
{
return obj is DistinctCountAggregateFunction;
}
public override string ToString()
{
return "Distinct Count";
}
protected override Cloneable CreateInstanceCore()
{
return new DistinctCountAggregateFunction();
}
protected override void CloneCore(Cloneable source)
{
}
}
public class DistinctCountAggregate : AggregateValue, IConvertibleAggregateValue<double>
{
private HashSet<object> aggregateValues = new HashSet<object>();
protected override object GetValueOverride()
{
return this.aggregateValues.Count;
}
protected override void AccumulateOverride(object item)
{
this.aggregateValues.Add(item);
}
protected override void MergeOverride(AggregateValue childAggregate)
{
DistinctCountAggregate distinctCountAggregate = childAggregate as DistinctCountAggregate;
if (distinctCountAggregate == null)
{
return;
}
foreach (var aggregateValue in distinctCountAggregate.aggregateValues)
{
this.aggregateValues.Add(aggregateValue);
}
}
bool IConvertibleAggregateValue<double>.TryConvertValue(out double value)
{
value = Convert.ToDouble(this.GetValueOverride());
return true;
}
}
Later it can be added to the pivot like this:
this.provider.AggregateDescriptions.Add(new PropertyAggregateDescription()
{
PropertyName = "Product",
AggregateFunction = new DistinctCountAggregateFunction()
});
Regards,
Hristo
Progress Telerik