我有一个如下所示的数据系列:
Cell Nam HSDPA User Capacity (Kbps)
68693A number
68693A number
68693A number
68693B number
68693B number
68693B number
68693C number
68693C number
68693C number
我想要做的是使用VBA创建一个数据透视表,首先将" HSDPA用户容量转换为Mbps" (通过1000分),然后返回每个" Cell Nam"
的平均值目前我正在使用以下代码:
'Creating Pivot table
Set objPivotTable = objPivotcache.CreatePivotTable(tempRange)
'Setting Fields
With objPivotTable
'set row field
With .PivotFields("Cell Nam")
.Orientation = xlRowField
.Position = 1
End With
'set calculated fields
.CalculatedFields.Add "HSDPA User Capacity (Mbps)", "='HSDPA User Capacity (kbps)'/1000"
'set data fields
.AddDataField .PivotFields("HSDPA User Capacity (Mbps)"), "Average of HSDPA User Capacity (Mbps)", xlAverage
.AddDataField .PivotFields("HSDPA User Capacity (Mbps)"), "Min of HSDPA User Capacity (Mbps)", xlMin
End With
但不是返回我的计算字段的平均值和最小值,而是返回总和
知道如何解决这个问题吗?
PS:当我只使用原始字段(除以1000之前),使用下面的代码一切正常
.AddDataField .PivotFields("HSDPA User Capacity (kbps)"), "Average of HSDPA User Capacity (kbps)", xlAverage
.AddDataField .PivotFields("HSDPA User Capacity (kbps)"), "Min of HSDPA User Capacity (kbps)", xlMin