Counting the digits of a number

Hi all - Quick one - I know how to get the specific number of characters of a text field:

Screenshot 2023-12-28 at 08.14.23

but when faced with a number field such as :

how can I get the number of digits? I can get the search the field and find the biggest number using the :max parameter but I’m not sure what to do after that…

Can anyone help please?
Thanks
Stewart

Hi Stewart,

Try using this:

Search for Datas: Each item’s Text Field 1: Format as text [Content to show per list item= This numver]: Extract with Regex [Regex Pattern = \d]: Count

Nothing fancy here. It is simply converting the list of numbers to a string, and then the regex is counting all numeric characters.

I’m not exactly sure what you want your final result to be (total number of characters, max number of characters), but this method can be adapted to your needs.

Hi Nico - Really appreciate you picking this up. I think your suggestion will work and I’m almost there:

But I cant see the regex option - there’s nothing in the drop down there and no checkbox that I can see.

Thanks again
Stewart

1 Like

Hi Stewart, glad to help.

The :extract with regex needs to be placed outside the :format as text (after it) as you need to use regex on the outputted formatted text.

I see it - apologies:


Let me try it out!

Ok - had a little play around. Your suggestion:

and:

gives me a result of 497 - looking at data table, specifically the Number Field 1 field, they largest number is a 5 digit one so that’s what I’m hoping to be returned.

Thoughts?
Stew

You said you wanted to count the number of digits in a search, which 497 is probably correct for.

What’s your use case? Are you sure you want to be counting the number of digits in a search? If not, what are you trying to do?

1 Like

Hi George.

Thank you for picking this up too.

I basically want to search a specific column in the data table and get the longest value and set that as the maximum character/digit length so I can then set a width size for it’s column in a table

To take a step back (which hopefully helps) I have a ‘Data’ table that is made up of 10 text fields (Text Field 1 through to Text Field 10), 15 number fields (Number Field 1 through to Number Field 15) and 3 date fields.

I then have a form that allows the user to upload a csv file (with the same headings) and this imports fine - here’s the App Data:

This workflow also creates a row in a ‘Fields’ table for each data field that isn’t empty - here’s the app data for that table:

During the process of the importing and then the creation of the fields, I also successfully get the count of characters for the text fields which then allows me to determine the width for each column in the following table:

I want to do the same for each number field. You’ll notice that the 6th column isn’t showing a title and that’s because I dont have a width set of length of 497 so it reverts to the min width size of 64.

Does that help?
Stew

I see…

Do a search for Datas:each item’s Number field:format as text(

Content: This number:formatted as (no thousands separator, 0 decimal places):number of characters
Delimiter: ,
)
:split by ,:each item converted to number:max

This should return the maximum number of digits in your search.

Hi George - worked perfectly (I had to add rounded to 0 as It was giving me fractions. Really appreciate yours and Nico’s help here.
Stew

This topic was automatically closed after 70 days. New replies are no longer allowed.