我正在尝试使用这一栏来计算警报类型的总体百分比。该列的工作方式是,如果它为“ 1”,则它在服务时间之内。如果它是“ 0”,则不是。我正在尝试添加一个“计算字段”以找到服务级别内多少警报类型的总服务时间百分比。但是我不确定如何使用循环来计算有多少个“ 1”并将其除以所有TTS返回值。该代码已返回数据透视表。我只是不确定如何返回其他“ TTS百分比”列。我在最后一段代码上遇到麻烦。
With xlPT
With .PivotFields("Generated")
.Orientation = xlPageField
'.Position = 1
.Caption = "Day Generated"
End With
With .PivotFields("Closed")
.Orientation = xlPageField
'.Position = 1
.Caption = "Day Closed"
End With
With .PivotFields("AlertDescription")
.Orientation = xlRowField
'.Position = 1
.Caption = "Alert Description"
End With
With .PivotFields("Status")
.Orientation = xlColumnField
' .Position = 2
.Caption = "Status"
End With
With .PivotFields("Inbox_Key")
.Orientation = xlDataField
.Function = xlCount
.NumberFormat = "#,##0"
.Caption = "Count of Status'"
End With
With .PivotFields("TTS")
.Orientation = xlRowField
'.Function = xlCount
'.NumberFormat = "#,##0"
.Caption = "Time to Serve"
End With
With .CalculatedFields.Add("TTS_Total", "=sum(TTS) WHEN TTS = '1'/Count(TTS)")
.Orientation = xlRowField
.Function = xlAverage
.NumberFormat = "0.00%"
.Caption = "Time to Serve %"
End With