How can I create a derived measure field dynamically, that calculates the distinct count of another field?
For example, take the flat table below that contains raw data depicting a list of men who went to an events and met women:
Male_Name
Event_Name
Female_Name
Jack
Concert
Ashley
Brittney
Party
Steph
Linda
Mixer
Amber
Bob
Ginger
Gail
Sophia
Chad
The following Pivot Grid shows the Event_Name as columns, Male_Name as rows and Number_Of_Girls_Met as the measure which is derived from the distinct count of Female_Names:
2
1
3
0
How do I make the measure field Number_Of_Girls_Met of type integer, without setting this up in the database?
Hello,
I have been looking into your question and I can suggest you look into the following sample from our website :
https://ko.infragistics.com/samples/silverlight/pivot-grid/#/flatdata-aggregators
Here custom aggregators are used.
If you need any further assistance, feel free to ask.
I don't think that's the same thing I'm asking for Nikolov. I specifically need a field that would show up in the "Measures" section of the tree that you will just have to drag into the measures section of the pivot grid. That Field should be, in sql terms, a DISTINCT COUNT of an existing field.
please ignore that last post, it's late and i didn't notice the double "count"
Hello,The cube settings should be added before items source is set because all metadata is processed when items source is set.FlatDataSource dataSource = new FlatDataSource();
dataSource.CubesSettings.Add(cubeMetadata);dataSource.ItemsSource = DatingViewModel.BoyMeetsGirlObservableCollection;
Regards.Plamen.
Thanks for all the help Plamen. However, that did not do anything. For the following example, I'm using this data model (obviously with a modified namespace)
http://help.infragistics.com/Help/Doc/Silverlight/2012.2/CLR4.0/html/SalesDataSample.html
I'm beginning to suspect this cannot be done with a simple xaml tag although I'm still hoping there's an easy answer. I tried attaching my solution but i've been getting a 500 server error. so here's the main xaml file:
<Grid x:Name="LayoutRoot" Background="White"> <Grid.Resources> <models:SalesDataSample x:Key="dataSample"/> <olap:FlatDataConnectionSettings x:Key="FlatDataConnectionSettings" ItemsSource="{StaticResource dataSample}" /> <olap:FlatDataSource x:Key="flatDataSource" ConnectionSettings="{StaticResource FlatDataConnectionSettings}" Cube="Sale" Rows="[Seller].[Seller]" Columns="[Product].[Product]" Measures="AmountOfSale" > <olap:FlatDataSource.CubesSettings> <olap:CubeMetadata DataTypeFullName="PivotGridSample.Models.Sale" DisplayName="Sale of the Greatest">
<!-- NOTE TO INFRAGISTICS: This is the derived measure I would like to get - A distinct count (Seller Count) of the dimension field (Seller),
: note that this measure does not exist in the model, I want to derive it from an existing dimension.
: Using your suggestions, this field does not show up on the measures tree of the data selector.
: Could it be because we need to make some kind of custom aggregator that we need to set in the "Aggregator" property? -->
<olap:DimensionMetadata SourcePropertyName="Seller"
DisplayName="Seller Count"
AggregatorType="DistinctCount"
DimensionType="Measure"/>
</olap:CubeMetadata> </olap:FlatDataSource.CubesSettings> </olap:FlatDataSource> </Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<ig:XamPivotGrid HorizontalAlignment="Left" Name="xamPivotGrid1" VerticalAlignment="Top" Grid.Column="0" DataSource="{StaticResource flatDataSource}"/>
<ig:Expander Grid.Column="1">
<ig:XamPivotDataSelector HorizontalAlignment="Left" Name="xamPivotDataSelector1" VerticalAlignment="Top" DataSource="{StaticResource flatDataSource}"/>
</ig:Expander>
</Grid>
</UserControl>
I have modified the TopCountAggregator so it can follow different behaviors now. You can find a working sample attached which I hope will cover your needs.
Best regards.Plamen.
Looks like something that I am looking too. I have a class Customer. How can I expose the property(Amount) of Order as a measure, if I create a Cube out of List of Customers(basically FlatDataSource).
public class Customer
{
string Name {get; set;}
Order CustOrder {get; set;}
}
public Order
string OrderNum {get; set;}
double Amount {get; set;}