Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
640
Derived Measure field from the distinct count of another field
posted

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

Jack

Concert

Brittney

Jack

Party

Steph

Jack

Party

Linda

Jack

Mixer

Amber

Bob

Mixer

Amber

Bob

Mixer

Steph

Bob

Party

Ginger

Bob

Party

Gail

Bob

Party

Sophia

Bob

Concert

Ashley

Chad

Concert

Steph

Chad

Concert

Linda

Chad

Concert

Brittney

Chad

Mixer

Amber

Chad

Mixer

Ginger

 

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:

 

 

Concert

Party

Mixer

Jack

2

2

1

Bob

1

3

2

Chad

3

0

2

 

How do I make the measure field Number_Of_Girls_Met of type integer, without setting this up in the database?

Parents Reply
  • 640
    posted in reply to [Infragistics] Plamen Pilev

    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>

     

Children