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

Display percent values together with raw values

10 Answers 12 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
LindenauAtSOG
Top achievements
Rank 2
LindenauAtSOG asked on 22 Dec 2020, 01:29 PM
Is it possible, to display both percent and the actual values behind them?
Right now you can either show percentage of total, or the actual value, but not both.

Or is there a way to get the "raw value" and "total value" of a CellAggregateValue programatically?

10 Answers, 1 is accepted

Sort by
0
Dinko
Telerik team
answered on 25 Dec 2020, 12:10 PM

Hi Christian,

Thank you for the provided image.

Modifying the way the total is calculated is not available in the implementation of RadPivotGrid. It displays the topmost aggregated calculation for the chosen aggregate description with its aggregate function. However, what you can try is to add calculated fields and calculated items to produce and display values that are a result of your custom calculations. I suggest taking a look at our documentation about calculated fields and calculated items:

- Calculated Fields
- Calculated Items

Also, you can check our "Calculated Fields" and "Calculated Items" examples available at http://demos.telerik.com/wpf/.

Then you could create a custom DataTemplateSelector class and return your custom template for the total cells. Keep in mind that this is just a suggestion, but still, you could try it on your side.

Regards,
Dinko
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
LindenauAtSOG
Top achievements
Rank 2
answered on 28 Dec 2020, 12:39 PM
Hi Dinko,

sadly, i fortogt to mention that we use Adomd, so I am afraid this doesnt work there?!

Also I do believe you misunderstood me at some point, so I try to rephrase what we are trying to do.
When displaying values, there is an option to display them as % of total.
However, when you select this, you only see that % of total, not the original value anymore.
We want to see both the original value and the % of total value.

I attached another picture for clarification.

0
Martin Ivanov
Telerik team
answered on 30 Dec 2020, 09:22 PM

Hello Christian,

Thank you for the clarification. If we got this correctly, you want to display both the original value and the percentage of the total value for the corresponding row or column. We will need some time to investigate possible approaches for this. We are going to contact you again within the next week.

Regards,
Martin Ivanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Martin Ivanov
Telerik team
answered on 04 Jan 2021, 12:01 PM

Hello Christian,

I've discussed your query with the development team and I am afraid that currently, there is no API that allows to get both the percentage and the absolute value of a cell. However, I've logged a feature request to introduce a mechanism to allow this. You can find it in the feedback portal where you can track its status. You can also find your Telerik points updated.

Regards,
Martin Ivanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
LindenauAtSOG
Top achievements
Rank 2
answered on 04 Jan 2021, 12:09 PM
Hello Martin,

thank you for checking the possibilities here.

Im not entirely sure, the Format is exactly needed. I allready managed to mess with the "displayed value" using a converter for the cell defined in the CellTemplate.

The only issue at this point is, that there is no way of getting the original value.
I got that "CellAggregateValue" object, but that only contains the aggregated value.

Anyway, if this is not a quater million, we would be willing to pay a reasonable ammout for that feature to be implemented.
0
Martin Ivanov
Telerik team
answered on 07 Jan 2021, 11:43 AM

Hello Christian,

The TotalFormat determines what value will be displayed in the cell. Creating a custom TotalFormat will allow you to implement  a custom logic that gets the original value, transform its value if needed and formatting it. For example, you can create a format where you show both the original value and the percentage. 

There is another suggestion that you can try and see if it will work instead of waiting for the feature. Basically, instead of using the command that shows the percentage of the value, you can use the default view where the absolute values are shown and implement a custom CellTemplate. In the CellTemplate, you can use MultiBinding to get the DataSource and the current CellAggregateValue which will allow you to fetch the absolute value of the cell and the grand total of the row/column. Then you can calculate the percentage and format the values. The formatted value will be the result of the Convert() method of the corresponding IMultiValueConverter. You can find this approach in the attached project. Can you try it and let me know if it works for you?

About feature implementation payments, I would suggest using the ticketing system from your telerik.com account and send it from there.

Regards,
Martin Ivanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
LindenauAtSOG
Top achievements
Rank 2
answered on 13 Jan 2021, 02:03 PM
Hello Martin,

thank you for the provided example.
We managed to get this working now.

Since there were a few more requirements, we had to do a few modifications, but everythings works like a charm now.

One thing to note its, that we had to use reflection, because a few things are internal and we couldnt find any other way.

        // Grand Total
        Coordinate co = results.Root;
 
        switch (zusatz)
        {
            case PivotWertZusatz.ColumnPercent:
                // ColumnTotal
                co = new Coordinate(results.Root.RowGroup, TelerikPivotHelper.GetCoordinateGroup(aggregateValue.ColumnGroup));
                break;
 
            case PivotWertZusatz.RowPercent:
                // RowTotal
                co = new Coordinate(TelerikPivotHelper.GetCoordinateGroup(aggregateValue.RowGroup), results.Root.ColumnGroup);
                break;
 
        }
 
        AggregateValue grandTotalAggregate = results.GetAggregateResult(aggidx, co);
 
 
 
// REFLECTION aggregateValue.RowGroup doesnt work, but its internal Group does.
private static PropertyInfo _internalGroupProperty;
public static IGroup GetCoordinateGroup(IGroup group)
{
    _internalGroupProperty ??= group.GetType().GetProperty("Group");
    return (IGroup) _internalGroupProperty.GetValue(group);
}
0
Martin Ivanov
Telerik team
answered on 18 Jan 2021, 09:46 AM

Hello Christian,

I am glad to hear the suggested approach worked for you. Also, thank you for sharing your solution here in the forum. I hope everything with your app development goes well.

Regards,
Martin Ivanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
LindenauAtSOG
Top achievements
Rank 2
answered on 18 Jan 2021, 09:50 AM
Hey Martin,

yeah everyone is nice now.
But please do not ignore the fact that we had to use reflection. Could you please add this to your ToDo list to make this property publically accessible at some point, or atleast make Coordinate work with aggregateValue.RowGroup directly.

0
Martin Ivanov
Telerik team
answered on 19 Jan 2021, 12:35 PM

Hello Christian,

I've logged this in the Telerik UI for WPF feedback portal where you can track its status. You can add any additional information to the item in the comments section. You can also find your Telerik points updated.

Regards,
Martin Ivanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
PivotGrid
Asked by
LindenauAtSOG
Top achievements
Rank 2
Answers by
Dinko
Telerik team
LindenauAtSOG
Top achievements
Rank 2
Martin Ivanov
Telerik team
Share this question
or