Hello
I just started considering Grist, I study the formulas I can’t understand how to find the maximum value in the current column.
There is such a task - to create an order number for the following algorithm: the number consists of 8 digits, the first six is the current date (for example, 250714) and two digits in order, generated in Google tables according to the following principle - the maximum order number in the current column is taken, the 6th numbers are checked, if this is today’s date, then we are an advanced 1, if not today, then we will comply with the number of the order number 25071401.
I cannot get max value of column
https://docs.getgrist.com/szjmgQoLV5cm/Untitled-document?utm_id=share-doc
Translated by Google
Hi! Unfortunately, we can’t access your shared document. You’ll have to make sure public access is on.
So sorry, make public access now.
hi, kind of interesting problem u have there. i dont know if this is the best practice for giving the unique order numbers, i think i might have implemented the formula what u need for this. check this out:
when u add new records or add dates, this formula will calculate the next running number from the previous records.
Do you mind sharing your formula for Order Number? It is blocked by access rules. I am going to do something similar to this for our purchase order system. It is similar to the original question.
We have 3 departments, Car Shop, Engine Shop, and CNC Shop. So a purchase order is something like CAR-071425-1, CAR-071425-2. So if there is no order for the department for the date, it gets -1. If there is, it increases by 1 like -2, -3.
I feel like this is doing the same thing, so it will be easy to adapt to my system
yes sure np. forgot to give the editor access, changed it now. in case its still not accessible here is the formula:
import datetime
curr_date = rec.Date.strftime('%y%m%d')
all_records = len([r for r in table.all
if r.Date and r.Date.strftime('%y%m%d') == curr_date
and r.id != PEEK(rec.id) and r.OrderNum is not None])
# Generate sequence number (starting from 1)
sequence = all_records + 1
return int(curr_date + str(sequence).zfill(2))
Thanks for sharing, this gives me a good starting point to adapt our system as well.
Farhan, That was SO SO SO helpful. Thank you so much.