I have a requirement that if user type something like 5k, then in textbox, it will change text to 5000, if 5M then text will change to 500000.
What i did, on change event of textbox, i wrote this code
If(!IsBlank(TextInput2.Text),
UpdateContext({output:
With(
Match(TextInput2.Text, "(?<threshold>[0-9]+\.?[0-9]*[mMbtTkK0-9]{1})"),
Upper(Text(threshold))
)});
UpdateContext({formattedValue:If("M" in output,Value(Substitute(output,"M","")) * 1000000,
If("K" in output,Value(Substitute(output,"K","")) * 1000,
If("B" in output,Value(Substitute(output,"B","")) * 1000000000,
If("T" in output,Value(Substitute(output,"T","")) * 1000000000000,
output
))))});,
UpdateContext({formattedValue:0}));
And set "formattedvalue" in the "default" property of textbox
It is perfectly working fine, the problem is that, if i type 9k it change to 9000 and if i remove the text and type 9k again then it leave it 9k only and not convert the value. First i thought "on change" event is not firing but it always fired, not sure if i type the same value why its not working. If i change to some other value then it worked perfectly.

Report
All responses (
Answers (