Hi there,
I am new to the community.
I was asked to check the length of the number of decimals after the decimal place
eg. 12.2123 - would give me 4
how can i check the length of the numbers after the decimal place as if i turn it into a v_w string i sometimes loose a zero at the end
eg. 12.20 - turns to 12.2 so when i check the length it gives me one
Solved! Go to Solution.
Hi there,
I am new to the community.
I was asked to check the length of the number of decimals after the decimal place
eg. 12.2123 - would give me 4
how can i check the length of the numbers after the decimal place as if i turn it into a v_w string i sometimes loose a zero at the end
eg. 12.20 - turns to 12.2 so when i check the length it gives me one
thanks
T
Far too much of a brute force way but:
LENGTH(REGEX_REPLACE(TOSTRING([Field1],12),"^-?\d+.?(\d*?)0*$","$1"))
Will get length (up to 12 dp).
Basically, it converts to a string and then uses a regular expression to get just the part of the string after the decimal point and before the trailing zeros.
Expect a better maths based approach but that should work
12.345
That's how I would approach this problem.
Cheers,
Mark
The extra issue ( just realised) some of the data does not have a decimal. so that length should be zero. i will get an error if i use the find string on those fields
If you use:
findstring("12345",'.')
your result will be -1.
IF FindString([field],".") = -1 THEN 0 ELSE Length([Field]) - (1 + FindString([Field],".") ENDIF
Will this work?
Hi all,
Two duplicate streams have been merged on this post (one looks to have inadvertently gone to the 'welcome to community' section)
Thanks!
just wanted to say thank you for your input
Taher
User | Count |
---|---|
18 | |
14 | |
13 | |
9 | |
8 |