This is a two step process, and as a result, the Field Calculator is not well suited to it. It is better to run this in a standalone script. However, it can be done in the field calculator, provided you use a trick. You do need to use a cursor to load all of the values to a global dictionary from a sorted list, but only during the calculation of the first record. For all other records you have to skip the dictionary creation to avoid constantly rereading the entire table for each row.
The three field values have to be placed in a tuple to act as a key that will sort properly. I will assume all 3-field combination values are unique in the SamplePoint table, but I added the ObjectID to ensure it is unique. You have to provide the path and shapefile name in line 8 (or I could use the technique that FelixIP uses where the first layer in the current map is used). If you want to use different fields for a key you have to change the field list in line 10 and match them with the input fields in line 3 and line 15.
#Pre-logic Script Code:
relateDict = {}
def autoIncrement(myYear, myMonth, myDay, OID):
global relateDict
# only populate the dictionary if it has no keys
if len(relateDict) == 0:
# Provide the path to the relate feature class/table
relateFC = r"C:\Users\OWNER\Documents\ArcGIS\SamplePoints.shp"
# create a field list with the relate fields in sort order
relateFieldsList = ["Year", "Month", "Day", "OID@"]
# process a da search cursor to transfer the data to the dictionary
relateList = sorted([(r[0:]) for r in arcpy.da.SearchCursor(relateFC, relateFieldsList)])
for relateSort in range(0, len(relateList)):
relateDict[relateList[relateSort]] = relateSort + 1
return relateDict[(myYear,myMonth,myDay,OID)]
#Expression:
autoIncrement(!Year!, !Month!, !Day!, !OBJECTID!)
I also would not recommend using field names of Year, Month and Day, since those only work in shapefiles and are not allowed in geodatabases. A geodatabase will change the names to Year_1, Month_1, Day_1 if you try to add them to the field list in the properties of the table.
If the purpose of this table is to relate it to another table/feature class on a multi-field key, consider using the tool I created in my Blog named Multiple Field Key to Single Field Key Tool - Relate Two Layers Based on More than One Field