'How to Group by Date Field in a PivotTable using win32com.client
I tried many approaches from last few hours but no luck. Somebody please help me.
group_dt = pt.PivotFields('Created')
group_dt.LabelRange.Group(Start=True, End=True, Periods=Array(False, False, False, False, True, False, True))
Error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-75-0355ab1abb88> in <module>
1 group_dt = pt.PivotFields('Created')
----> 2 group_dt.LabelRange.Group(Start=True, End=True, Periods=Array(False, False, False, False, True, False, True))
TypeError: 'str' object is not callable
Solution 1:[1]
After a lot of research I have figured out the way to group date field using win32com.client
cell = pivot_sheet.Range('B5')
cell.Group(Start=True, End=True, Periods=list([False, False, False, False, True, False, True]))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Gulam Jeelani |