I have code that creates a pivot table with % difference from below. It works just as you would expect but the problem comes in when the first value is negative. For example, I have -10 as the first value and 15 as the second value. Excel calculates this as (15-(-10)) / -10 or -250%, which this should be positive. Are you able to add code to the .calculate below so if the old value is negative divide by its absolute value or is there another method to go about this?
pt.AddDataField pt.PivotFields("Amount"), "Amount ", xlSum
With pt.PivotFields("Amount ")
.Calculation = xlPercentDifferenceFrom
.BaseField = "Month"
.BaseItem = "(next)"
.NumberFormat = "0.00%"
End With
Bookmarks