Discussions

Expand all | Collapse all

Convert a number to text

  • 1.  Convert a number to text

    Posted 08-25-2021 09:11
    I need to pad a number with 2 leading zeros to be able to read a legacy bar code.  The ToFormattedText function does not actually convert the number so I can't use the PadLeft function.  I know there has to be a way to convert a number to text, but I can not seem to find the right function.  Any help would be appreciated.

    ------------------------------
    Julie Meeker
    ------------------------------


  • 2.  RE: Convert a number to text

    Posted 08-25-2021 09:17
    How about this as a formula text field.

    var text MyBarCode = ToText([my bar code field]); 
    IF(not begins($MyBarCode, "00"), "00" & $MyBarCode, $MyBarCode)




    ------------------------------
    Mark Shnier (YQC)
    mark.shnier@gmail.com
    ------------------------------



  • 3.  RE: Convert a number to text

    Posted 08-25-2021 09:41
    Can you explain a little more please.  I am not finding a var text  or not begins function in the list.  what does $ represent?

    ------------------------------
    Julie Meeker
    ------------------------------



  • 4.  RE: Convert a number to text

    Posted 08-25-2021 09:46
    I'm all about super tidy and readable formuals since in all probability I will be the one who needs to look back at a formula I did years ago to see what it is doing, or if its someone else, the the formulas should be stupid simple to read.

    So I like to use Formula Variables.  here is some help on them.
    https://help.quickbase.com/user-assistance/formula_variables.html

    Maybe in this case it was overkill.

    You can also just do this

     
    IF(not begins([My bar code field], "00"), "00" & [My bar code field], [My bar code field])





    ------------------------------
    Mark Shnier (YQC)
    mark.shnier@gmail.com
    ------------------------------



  • 5.  RE: Convert a number to text

    Posted 08-25-2021 09:52
    Thank you for the article link.  When I use that formula I still get the error that it is expecting text and I gave it a field that is a number.

    ------------------------------
    Julie Meeker
    ------------------------------



  • 6.  RE: Convert a number to text

    Posted 08-25-2021 09:54
    The field type for the formula need to be formula text.  A numeric field cannot begin with 0, so you will need to use a text field type.

    ------------------------------
    Mark Shnier (YQC)
    mark.shnier@gmail.com
    ------------------------------



  • 7.  RE: Convert a number to text

    Posted 08-25-2021 10:06
    Hence my original question.  How can I convert a number to text?

    ------------------------------
    Julie Meeker
    ------------------------------



  • 8.  RE: Convert a number to text

    Posted 08-25-2021 10:21
    QuickBase has a built in function for formula fields! ToText([field]) 



    ------------------------------
    Katlyn Allen
    ------------------------------



  • 9.  RE: Convert a number to text

    Posted 08-25-2021 11:07
    Right, so that is why I did this in my original response.

    var text MyBarCode = ToText([my bar code field]); 
    IF(not begins($MyBarCode, "00"), "00" & $MyBarCode, $MyBarCode)


    My second simpler response was incorrect.

    ------------------------------
    Mark Shnier (YQC)
    mark.shnier@gmail.com
    ------------------------------