This is a migrated thread and some comments may be shown as answers.

Getting a count of non-null values in a DataTable attached to a LocalDataSourceProvider

3 Answers 221 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
Grinden
Top achievements
Rank 1
Grinden asked on 24 May 2017, 03:46 PM

Hi,

I have a LocalDataSourceProvider bound to a DataTable. Some of the columns allow nulls and some of the values in them are DBNull. I would like to be able to display a count of the values that aren't null. I've created my own aggregate function and I can add that to some of my AggregatePropertyDescriptions programmatically. I do have an example, but apparently I'm only allowed to upload images.

The questions I've got are:

Is there any easier way to do this?

Can I make this aggregate function appear in the UI in the Field List, so users can select it?

I only appear to be able to apply this to my nullable int property, and not my string property. Is that something I should be expecting?

Many thanks,

Richard

3 Answers, 1 is accepted

Sort by
0
Grinden
Top achievements
Rank 1
answered on 24 May 2017, 03:47 PM
You can remove the .jpg extension to unzip it.
0
Accepted
Polya
Telerik team
answered on 29 May 2017, 11:28 AM
Hello Richard,

With the R2 2016 release of UI for WPF the IgnoreNullValues property was introduced for the PropertyAggregateDescription. This property is of type bool and it is used to determine whether a specific PropertyAggregateDescription should ignore the null values when calculating its result. You can find more information about this property and how to use it in this help article: http://docs.telerik.com/devtools/wpf/controls/radpivotgrid/populating-with-data/data-localdatasource

That said you can use the Count aggregate function for the PropertyAggregateDescription and set IgnoreNullValues=true to achieve the desired:

DataTableDataProvider.AggregateDescriptions.Add(new PropertyAggregateDescription() { PropertyName = "Name", AggregateFunction = new CountAggregateFunction(), IgnoreNullValues = true });

Hope this helps.

Regards,
Polya
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Grinden
Top achievements
Rank 1
answered on 22 Jun 2017, 02:45 PM

Hi Polya,

That's great, just what I needed.

Thanks very much.

Richard

Tags
PivotGrid
Asked by
Grinden
Top achievements
Rank 1
Answers by
Grinden
Top achievements
Rank 1
Polya
Telerik team
Share this question
or