Create a Counter but the Count Starts Over the Next Month

Hello,

I need a formula that counts from 1 to whatever until the end of the month. Then when the month starts over the count will reset. I have a date column called $Date_for_ID. The column that the number will increment is called $Count.

So for example it will look like this:
June
1
2
3
4
Then in July it starts over:
1
2
3
4 and so forth.

I have tried all sorts of python code. This one so far works but the output I get is 1. It does not increment up.

from datetime import datetime

current_month = datetime.now().month
count = (current_month - $Date_for_ID.month) * 99 + 1
count

Any help would be appreciated.

For performance reasons, I think the best way is to add a Month column (which you may hide), and use a lookupRecords (sample here):

table.lookupRecords(Month=$Month, sort_by="Date_for_ID").id.index($id) + 1

To avoid problems next year, the Month column must keep information about the year:

($Date_for_ID.year, $Date_for_ID.month)
1 Like

Thank you,

This works. I appreciate your help!!!