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
235
Single Total for multiple columns
posted

Hello,

Using the XamPivotGrid 13.1 I am trying to get a single total column when pivoting on 2 columns. I dont want to see totals per dimension, i just want a single total column at the end.

As an example, the code below makes a flat data source with city vertically and years + fruit horizontally           

          var flatDataSource = new FlatDataSource
            {
                ItemsSource = GenerateRandomData(),
                Cube = XmlaDataSource.GenerateInitialCube("Datum"),
                Rows = XmlaDataSource.GenerateInitialItems("[City].[City]"),
                Columns = XmlaDataSource.GenerateInitialItems("[Year].[Year], [Fruit].[Fruit]"),
                Measures = XmlaDataSource.GenerateInitialItems("Value"),
            };
            // Totals
            var cityHierarchy = new HierarchyDescriptor<Datum>(p => p.City);
            cityHierarchy.AddLevel(p => "City", "City Total");
            cityHierarchy.AddLevel(p => p.City, "City");
            flatDataSource.AddHierarchyDescriptor(cityHierarchy);
            var fruitHierarchy = new HierarchyDescriptor<Datum>(p => p.Fruit);
            fruitHierarchy.AddLevel(p => p.Fruit, "Fruit");
            flatDataSource.AddHierarchyDescriptor(fruitHierarchy);
            var yearHierarchy = new HierarchyDescriptor<Datum>(p => p.Year);
            yearHierarchy.AddLevel(p => "Year", "Year Total");
            yearHierarchy.AddLevel(p => p.Year, "Year");
            flatDataSource.AddHierarchyDescriptor(yearHierarchy);

With 2 years and 2 fruits, this produces a table with the following headers

2015/Banana, 2015/Apple, 2014/Banana, 2014/Apple, Year Total/Banana, Year Total/Apple

What i require is

2015/Banana, 2015/Apple, 2014/Banana, 2014/Apple, Total

Please see the attachment for a project showing the existing pivot grid and a screen shot of the required. For some reason i dont seem to be able to upload images to the forums.

PivotExample.zip
Parents
No Data
Reply Children
No Data