Hi all, I have a four number item. For Example "3423".
I want to get the 1st number of the four, then the 2nd , 3rd etc.
So column 1 would be the first number,
column 2 would be the 2nd
and so on. How can I split the 4 numbers apart?
Solved! Go to Solution.
LEFT([FOUR_DIGIT_NUMBER],1) for first digit.
If you wish the extracted part to be a number type, please wrap it by NUMBER()
NUMBER(LEFT([FOUR_DIGIT_NUMBER],1))
Similarly, please follow for extracting other numbers by using MID() function for second and third digit and RIGHT() for the fourth digit.
NUMBER(RIGHT([FOUR_DIGIT_NUMBER],1)) should give the 4 th digit.
LEFT([FOUR_DIGIT_NUMBER],1) for first digit.
If you wish the extracted part to be a number type, please wrap it by NUMBER()
NUMBER(LEFT([FOUR_DIGIT_NUMBER],1))
Similarly, please follow for extracting other numbers by using MID() function for second and third digit and RIGHT() for the fourth digit.
NUMBER(RIGHT([FOUR_DIGIT_NUMBER],1)) should give the 4 th digit.
Worked perfectly. Another item I can now use in the future. Thank you as always!
You are welcome.
To extract digits from right to left, regardless of length, you could use MID and LEN to get digits from [any_digit_number]
*Because this uses TEXT, you must ensure "Show Thousands Separator" is turned off on [any_digit_number]. Otherwise it will count the "," Thousand Separator as a character, even if it isn't visible for other reasons in your app.
First digit from the right:
MID(
[any_digit_number],
LEN(TEXT([any_digit_number])),
1
)
Second digit from the right:
MID(
[any_digit_number],
LEN(TEXT([any_digit_number]))-1,
1
)
and so on.
If you are using it in an expression, wrap in NUMBER().
Otherwise, if you are storing it in a Number column, I believe AppSheet will resolve it correctly. Wrap in NUMBER() to be safe.
@Suvrutt_Gurjar if this will fail for a reason I don't know of, please correct me.
Thank you @MMMiles for sharing a more standardized approach to extract digits from a number.
I believe wrapping by NUMBER() is necessary if result is desired as a number.
User | Count |
---|---|
14 | |
11 | |
9 | |
7 | |
4 |