PDA

View Full Version : Sorting in PivotTable or Hiding a PivotField



Babli
03-20-2007, 01:39 AM
Hi,

I am building a PivotTable in an asp.net page using vba code.

Set vwView = frmTest.PivotTable1.ActiveView
frmTest.PivotTable1.ConnectionString = "Provider=sqloledb;Integrated Security=SSPI;Data Source=chnshl66051;initial catalog=MyDb"

where frmTest is the form and PivotTable1 is the PivotTable object.

frmTest.PivotTable1.CommandText = "Select WebPage,SiteUrl,Title,UserName,Hits from Table order hits desc"

vwView.RowAxis.InsertFieldSet vwView.FieldSets("WebPage")
vwView.RowAxis.InsertFieldSet vwView.FieldSets("SiteUrl")
vwView.RowAxis.InsertFieldSet vwView.FieldSets("Title")
vwView.RowAxis.InsertFieldSet vwView.FieldSets("UserName")
vwView.RowAxis.InsertFieldSet vwView.FieldSets("Hits")

The issue is the Pivot table is sorting the data by the first column WebPage and not by Hits column.

I want it to sort it numerically.

Or please tell me is there any way to hide a PivotField.
Tried a lot for days together.

Help needed.