Forum Discussion
17 Replies
Sort By
- QuickBaseCoachDQrew CaptainThere may be other ways but this might be quick and dirty as a formula checkbox field. But this will fail if the number has a leading zero like 0123. If that is possible, then the formula will need to be a bit fancier.
ToText(ToNumber([maybe a number]))=[maybe a number] - MichaelBarrowQrew CadetThanks Mark. That's clever, but I couldn't get it to work. For my current purposes, this seems to have done the trick.
Length([Subject Form ID]) > 0 and Left([Subject Form ID],1) >= "1" and Left([Subject Form ID],1) <= "9"
It really bugs me, though, that there isn't a native function to do something so straightforward and necessary. - QuickBaseCoachDQrew CaptainI did test that formula and it did seem to work for me ... did you have a string that failed that I could test it on. The useful idea is that the ToNumber( ) function will return blank it what you give it contains non numeric characters.
In my test, the field for [maybe a number] was a text string.- SuryaAvantsa1Qrew MemberThat could be a problem. What if it was a blank? And the tonumeric also returns a blank. Then they both will be equal, thus misleading us to believe that a blank is numeric.
I guess, we need to first filter out blanks and call them non-numeric right away before checking for non-blanks.
if (Contains([may be a number]," ",false,ToText(ToNumber([maybe a number]))=[maybe a number]) - QuickBaseCoachDQrew Captainto test for a blank you would use
IF(Trim([my text field])="", true)
ie you test against empty quotes - SuryaAvantsa1Qrew MemberTrue. I agree.
- MichaelBarrowQrew CadetYeah, I would have though it would work for me,but it didn't. The particular piece of text that was a problem was 'Oneil (starting with an apostrophe). For my purposes, I am extracting FormID's which are all positive integers from 2 to 5 digits long, so I took the simple way to just test the first character, but I would like to get your more universal approach to work too, for what I'm sure will be later needs for this functionality.
- QuickBaseCoachDQrew CaptainI tried 'Oneil on my formula and it correctly said it was not a number
- MichaelBarrowQrew CadetHmm. Thanks for letting me know. I'll have to go back and do some more testing when I have time. Too much else going on with this project right now - I need to keep moving. Thanks again for your help!
- _anomDiebolt_Qrew EliteI would avoid getting into a situation where you have either text or a numeric value in a text field in the first place. Rethink your fields and calculations. Ambiguous data (text/numbers) should be cleaned up at the point of key entry or importing.
You probably could do a simple formula knowing that a number in a business setting consists of a {set of digits} possibly proceeded by a plus or minus sign and at most one decimal point amid the digits but it is just an exercise if difficulty.
QuickBase does not use scientific notation for numbers but technically you could have this in your string and ToNumber () will convert it correctly.
ToNumber("34e5") => 3400000
Or you could use JavaScript where any manner of parsing and data conversion is possible. Anyone here that could write a formula to accomplish the task you ask about could do it easier in JavaScript. Replace the formula language with JavaScript is my advice.
It strikes me as extremely odd that for a no code platform the first thing you have to do is master the formula language and all its quirks. _\_(_)_/__ - Zaya__OSSE-ContQrew TraineeSorry to resurrect an old post but this is the closest post I've found that's similar to the problem I'm struggling with.
I have a text field that's supposed to have all numbers except for dashes. I need to do IsNumeric type of validation. While Mark's formula is working great, my field can start with 0 so I can't use it. And changing the field to numeric is not an option at this point due to other dependencies. I've tried many different approaches with no luck. Any help would be greatly appreciated.- GiuseppeMacriQrew Captainif it starts with a 0, why not create a formula to remove the initial 0?
- AustinKQrew CommanderWhen I needed to verify something was a number(mine had 2 dashes between the numbers) I made a formula checkbox that would trigger if it was not a good number. I removed the dashes with a Part formula and then put all 3 parts back together in a variable. Then I tested to see if the number was above or below a certain number. My number was similar to a phone number so I checked if it was more than 0000000000 and less than 9999999999. If it returned true then it was a number. If it returned false it was not and I could abort the save.
The main issue with this approach is that for form rules to take effect the person needs to enter the data in the field and then click outside of the field to another one. If they do not do this then the form rule fails and the save happens.
I came to the conclusion that the best way to do this is with JavaScript. You can actually validate data with that and prevent people from entering the wrong thing. It's a nightmare doing it native in QuickBase imo. - QuickBaseCoachDQrew CaptainCan you tell me what the format is, especially how many digits there are, excluding the dashes? Maybe post a typical example?