Not getting the count of each number in the pivot column(2nd column) but same value as first column, while writing code to Excel from python

Viewed 12

I tried the following lines(excerpt) to build pivot table on a single numerical column to identify number of times each value repeats. This throws 2 columns of same value and grand total. I'm unable to get the desired result. Pls suggest.

wb.ActiveSheet.PivotTables(PivotTableName).PivotFields('Amount').Orientation = win32c.xlRowField wb.ActiveSheet.PivotTables(PivotTableName).PivotFields('Amount').Position = 1 wb.ActiveSheet.PivotTables(PivotTableName).PivotFields('Amount').Orientation = win32c.xlDataField

Note: Also tried wb.ActiveSheet.PivotTables(PivotTableName).PivotFields('Amount').Function=win32c.xlCount, and not working either.

Data

NumField
24
36
24
24
36

Expected Pivot Result in Excel after writing python code

enter image description here

0 Answers
Related