Hi,
The requirement that I have is to create a custom calculated aggregator in order to get the Percent of total of a Measure, I have tried to use PercentOfTotalAggregator (see link) unsuccessfully!
I am currently using version 11.1
I would appreciate about example code.
Thanks!
Hello,
This aggregator implementation refers to functionality which is not supported yet and is reserved for future uses.
Plamen.
Hello again,
Actually after I answered you I’ve looked again at your case and there is a way you can use this aggregator with some limitations:
1. This aggregator implements ICompoundAggregator and is based on another aggregator:
<!—Measure over simple aggregator-->
<olap:DimensionMetadata SourcePropertyName="Cost"
DisplayName="Model Price"
GroupName="Model Price"
DimensionType="Measure" DisplayFormat="{}{0:C3}">
<olap:DimensionMetadata.Aggregator>
<olap:DoubleSumAggregator Identity="DoubleOfCost"/>
</olap:DimensionMetadata.Aggregator>
</olap:DimensionMetadata>
<!—Measure over compound aggregator-->
<olap:DimensionMetadata DisplayName="Model Price (%)" GroupName="Model Price"
DimensionType="Measure" DisplayFormat="{}{0:0.##} %">
<olap:PercentOfTotalAggregator>
<olap:PercentOfTotalAggregator.Parts>
</olap:PercentOfTotalAggregator.Parts>
</olap:PercentOfTotalAggregator>
When you add the measure based on the compound aggregator to measures collection its base measure have to be already present to the measures. The compound aggregators connects to its parts through their Identity.
2. In order these measures to appear in metadata tree you have to enable mixed mode for dimension generation:
<olap:FlatDataSource x:Key="flatDataSource" ParentInFrontForColumns="True"
MeasureListLocation="Columns"
DimensionsGenerationMode="Mixed"
...
3. Because we have set MeasureListLocation="Columns" all other hierarchies should be placed in the rows area
Have a look at the snapshot below. Also in order to calculate the percentages properly before add the compound measure you need to have already expanded the Date hierarchy.
Please note that in the future we can change the way this functionality works.
Regards.Plamen.
I saw this post and had a few questions that I was hoping to run by someone. I'm new to both infragisitics, wpf, and Xaml. So the question might be a bit basic. However, if I wanted to do this same thing in C# rather then xaml, how would I go about that? I've thrown together a sample project(just the introduction to infragistics tutorial) and am trying to replicate this solution in that. I think I've gotten most of it, but the 'PercentOfTotalAggregator.Part' is throwing me for a loop. If I understand the code right, this is the way you hook it up to the other aggregator(through the identity). But how would I replicate this in C#? Since '.part' only has a 'get', how do I connect them?
Basically:
var percentageMeasure = new DimensionMetadata(){
DisplayName ="Model Price (%)",
GroupName ="Model Price",
DimensionType = DimensionType.Measure,};
percentageMeasure.Aggregator =new PercentOfTotalAggregator();
//But how do I connect it to the other aggregator that I made as a part of a different DimensionMetadata earlier in the code?
myCubeMetadata.DimensionSettings.Add(percentageMeasure);
The equivalent of the XAML Plamen suggested is the following one:
DimensionMetadata percentageMeasure = new DimensionMetadata() { DisplayName = "Model Price (%)", GroupName = "Model Price", DimensionType = DimensionType.Measure, }; PercentOfTotalAggregator pota = new PercentOfTotalAggregator(); pota.Parts.Add(new DoubleSumAggregator() { Identity = "DoubleOfCost" }); percentageMeasure.Aggregator = pota;
Hope this helps you.
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.
Thanks. I had tried 'pota.Parts.Add(otherAggMeasure.Aggregator);', but it didn't seem to want to make TotalPercentageAggregator play nicely. I actually dealt with it a little before you replied by just writing a custom aggregator that does the same thing as TotalMeasureAggregator. Everything seems to be good to go and it passed testing, so it looks like my issue is resolved.
-Faelin