web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / OnChange event is not ...
Power Apps
Answered

OnChange event is not updating if text is same

(0) ShareShare
ReportReport
Posted on by 20

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.

rajeshrai1231_0-1707734876645.pngrajeshrai1231_1-1707734891836.png

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}));

rajeshrai1231_2-1707734967214.png

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. 

 

Categories:
I have the same question (0)
  • Verified answer
    BCBuizer Profile Picture
    22,833 Super User 2026 Season 1 on at

    Hi @rajeshrai1231 ,

     

    The issue is that upon entering the same value for a second time, the formattedValue variable doesn't change value. Since it will contain the same value, the Text Input control will not trigger the behaviour to take the value as referenced in the Default property. By resetting the variable as part of the process, you can fix this issue:

     

    If(!IsBlank(Self.Text),
    UpdateContext({output:
    With(
    Match(Self.Text, "(?<threshold>[0-9]+\.?[0-9]*[mMbtTkK0-9]{1})"),
    Upper(Text(threshold))
    )});
    UpdateContext({formattedValue:0});
    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}));

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 366 Most Valuable Professional

#2
11manish Profile Picture

11manish 184

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 99 Super User 2026 Season 1

Last 30 days Overall leaderboard