How Change Default from Count to sum Pivot Table

shonaart

Board Regular
Joined
Nov 1, 2004
Messages
214
Hi
Please can you tell me how I can change default from count to Sum in a pivot table.
I know that if cells have no data in them it goes to count , but my spreadsheet is too large to go in and add zeros etc.

Thanks
Vaughan
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
I think you've answered your own question...it will default to SUM if all the values in the field are numeric. If just one is non-numeric, e.g. blank "", then it will assume a COUNT is the more appropriate function.
 
Upvote 0
Hi,
I know, so is it possible to force it to sum. Also it does not bring the correct number formate through. The spreadshet is in [H]:mm formate but bring another formate through. Very fustrating when you have a large number of fields.
Thanks
Vaughan
 
Upvote 0
I don't believe so. If you forced it to SUM every time, what would you want to happen when it encountered a text value?

The number format issue can be frustrating. I use a bit of code to fix the number formats. Pretty simple, but it could be adapted. It assumes the active cell is within the Pivot Table you want to change.

Code:
Sub ConvertDataFieldsNumberFormat()
Dim strField As String, strNumFormat As String, strNumFormatDef As String
 
Set PT = Nothing
strNumFormatDef = "#,##0"
 
On Error Resume Next
Set PT = ActiveCell.PivotCell.PivotTable
On Error GoTo 0
If PT Is Nothing Then
    MsgBox "Not in a Pivot Table"
    Exit Sub
End If
 
strField = Application.InputBox("Enter the search term for the Pivot Fields to be changed:" & _
    vbCr & vbCr & "(leave blank to change all Pivot Fields)", strTitle, Type:=2)
If strField = "False" Then Exit Sub
 
strNumFormat = Application.InputBox("Enter the number format to apply to the Pivot Fields:" & _
    vbCr & vbCr & "leaving this blank will default to ""#,##0"", e.g. 1,000", strTitle, strNumFormatDef, Type:=2)
If strNumFormat = "False" Then Exit Sub
If strNumFormat = "" Then strNumFormat = strNumFormatDef
 
'you could turn off Screenupdating, Pivot table updating here if it runs slowly
For Each PF In PT.DataFields
    If InStr(1, PF.Name, strField) <> 0 Then
        PF.NumberFormat = strNumFormat
    End If
Next PF
'and turn it back on again here

End Sub
 
Upvote 0

Forum statistics

Threads
1,216,029
Messages
6,128,403
Members
449,448
Latest member
Andrew Slatter

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top