We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Pivot Table: Show Values As % of Row Total

Hello ~

In Excel on a Pivot Table, when you define something in the Values section, you can go to the Value Field Settings, go to the Show Values As tab and choose "Show values as" to be "% of Row Total".  Can that be replicated using xlsio?  Screen print below of the dialog box I'm talking about.

Thanks!



2 Replies

PK Prakash Kumar D Syncfusion Team November 13, 2018 10:12 AM UTC

Hi Steve, 
 
Thank you for contacting Syncfusion support. 
 
Your requirement can be achieved by using IPivotDataField.ShowDataAs  property. Please refer the code snippet below. 
 
Code snippet: 
IPivotCache cache = workbook.PivotCaches.Add(pivotSheet["A1:D40"]); 
 
IPivotTable pivotTable = pivotSheet.PivotTables.Add("PivotTable1", pivotSheet["A50"], cache); 
pivotTable.Fields[0].Axis = PivotAxisTypes.Page; 
pivotTable.Fields[2].Axis = PivotAxisTypes.Row; 
pivotTable.Fields[1].Axis = PivotAxisTypes.Row; 
pivotTable.Fields[3].Axis = PivotAxisTypes.Column; 
 
IPivotField dataField = pivotSheet.PivotTables[0].Fields[3]; 
pivotTable.DataFields.Add(dataField, "Sum of Units", PivotSubtotalTypes.Sum); 
 
//Set show data  
pivotTable.DataFields[0].ShowDataAs = PivotFieldDataFormat.PercentageOfRow; 
 
Please let us know if you need further assistance on this. 
 
Regards, 
Prakash Kumar 



SG Steve Good November 13, 2018 03:52 PM UTC

Perfect ~ thank you!

Loader.
Live Chat Icon For mobile
Up arrow icon