How can i make formula to to ensure the a string is formated like a mac-address.
ex: e4-c3-2a-db-b9-98
in my row i have: E4-A3-1C-DB-B9-98
or with : in bettwen
How can i make formula to to ensure the a string is formated like a mac-address.
ex: e4-c3-2a-db-b9-98
in my row i have: E4-A3-1C-DB-B9-98
or with : in bettwen
If I understand you correctly, you just want to transform what you already have in your row to lowercase? In that case, make a trigger formula on the column, trigger on any changes to self, and just put return str(value).lower(). That should do the trick…
I have play around some and com upp with.
this Forumula.
return ‘:’.join([value.replace(“:”, “”).replace(“-”, “”).upper()[i:i+2] for i in range(0, 12, 2)])
is it posible to implement this i the curren colmun..?
or even better to make a custom column type. thant can take care formating of the current column.
I think you are already using Trigger Formulas to format the data as it’s entered into this column, right? For formatting existing values, you can either create a temporary column with a regular formula to calculate cleaned up values, and then copy-paste those values back; or you can use Apply transfrom to data feature, which is basically the same but transforms a column in-place. In either case, I believe you’ll need to replace value with $Your_Column to do this step.
Thanks for the. help @dmitry-grist , is it posible to make a multiline pythonfuntion for the return?
Yes its posilbe to make mulitine python formulas.
I have come upp with this but i ge some error “Curcular refrence”
# Remove any existing separators like ':' or '-'
cleaned_mac = $Mac_Address.replace(":", "").replace("-", "").upper()
# Check for the correct length
if len(cleaned_mac) != 12:
return None
# Group the digits and join
formatted = ':'.join([cleaned_mac[i:i+2] for i in range(0, 12, 2)])
return formatted
Yes, Shift-Enter is how you add newlines.
The “Circular Reference” is when a cell depends (directly or indirectly) on its own value. Regular formulas can’t do that. Trigger Fromulas and “Apply transform to data” can, but confusingly, Trigger Formulas must refer to the value using the special value variable, while “Apply transform to data” must use the column name. I.e. your formula should work for “Apply transform to data”, but for Trigger Formula, change this line from:
cleaned_mac = $Mac_Address.replace(":", "").replace("-", "").upper()
to
cleaned_mac = value.replace(":", "").replace("-", "").upper()
(The “Transforms” existed before Trigger Formulas were added, and hasn’t gotten the attention to make it more consistent and friendlier.)