Is there a way to check if a field has more characters than a specific amount?

Hi!

I am trying to set up a beast mode function that checks if fields are correctly filled out in our asset tracking software, and lists out any asset that does not meet all requirements (ie fields not filled out or have been auto-generated by the software itself).

One thing I am curious about is, I'd like to be able to include a function that can see if either one field (Serial Number) is empty OR has more than 7 characters included. I am fairly new to beast mode calculations, and we have most everything working properly to check all empty (NULL) fields and one field if it is either empty or auto generated (LIKE 'EXAMPLE-%'), but I'm not totally sure if or how to check if the character count is more than 7 characters in a field.

I hope I'm making some sort of sense here. And thank you for any advice!

Tagged:

Best Answer

  • GrantSmith
    GrantSmith Coach
    Answer ✓

    Hi @JoeR_PSIT

    You can use the LENGTH function to get the number of characters in a string

    CASE WHEN `Serial Number` IS NULL OR LENGTH(`Serial Number`) > 7 THEN 'Error' ELSE 'OK' END
    
    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**

Answers

  • GrantSmith
    GrantSmith Coach
    Answer ✓

    Hi @JoeR_PSIT

    You can use the LENGTH function to get the number of characters in a string

    CASE WHEN `Serial Number` IS NULL OR LENGTH(`Serial Number`) > 7 THEN 'Error' ELSE 'OK' END
    
    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**
  • Thank you Grant! That was such a quick and helpful answer. I have tested it and while it will take some work to get it working with a more complex beast mode calculation, that is EXACTLY what I was looking for! Time for some trial and error and try to push this further :D

    Thank you again! I really appreciate it!