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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Set field value of dif...
Power Apps
Answered

Set field value of different Field onChange

(0) ShareShare
ReportReport
Posted on by

I've got the following problem:

I have three fields: Gross and Net Values of a purchased item, aswell as sales tax.

 

As soon as either the Net value or the sales tax (drop down field) gets changed, i want the Gross value to be updated accordingly. The formular would be something similar to [ Net.Text * (Tax.Selected.Value/100+1) ] -> (If any of that formular doesnt make sense to you, I'm from Austria so that might be why). At the end of the day i just need to know how to update the Gross Value field when one of the other changes. 

Thank you advance!

Categories:
I have the same question (0)
  • iAm_ManCat Profile Picture
    18,228 Most Valuable Professional on at

    Can you describe how this is currently set up and possibly provide screenshots?

    Is Gross an inputText? Is this within a gallery? Is there a reference to this particular item so that you could patch the value directly each time? Is it just a label showing or are you storing the value for Gross?

  • Community Power Platform Member Profile Picture
    on at

    I am remodeling an old infopath form. Both Gross and Net Value are input-fields, while sales tax is a dropdown. 

     

    I could send screenshots if needed, however the form is in german (So you probably wouldn't understand much) and it won't give you a lot more info than that. 

     

    The Components are:

    - "Kaufbetrag_Datacard1", where the Net input field is in ("Kaufbetrag")

    - "Umsatzsteuer_Datacard2", where Sales tax is in("MwstValue")

    - "Kaufbetrag mit Steuer_Datacard", where the Gross input-field is ("KaufbetragMwstValue")

    It would also be great if it would be possible in both ways. Meaning that you could either enter Net value and it calculates gross value, or the other way around!


  • Community Power Platform Member Profile Picture
    on at

    As additional info, i tried filling in the onChange property of MwstValue with the following code:

     

    Set(KaufbetragMwstValue,Value(Kaufbetrag.Text)*MwstValue.Selected.Value)

     

    But it shows an error on the "KaufbetragMwstValue" part, saying "Unexpected Characters. The formular contains 'Control' where "ident" is expected".

  • Verified answer
    iAm_ManCat Profile Picture
    18,228 Most Valuable Professional on at

    Ok, so you don't set control values that way unless you are using variables as their default values - Power Apps is more like Excel, where a cell's formula defines its value, so you might put a formula on Cell A1, and the formula would be B2 + B3

     

    I will include a proof-of-concept app that shows the basic principle, you can open this from within the editor by using the ellipsis, then Open:

    image.png

    image.png

    image.png

     

    So what I've done is:

    Set the Default value of Kaufbetrag to gblNet

    Set the Default value of KaufbetragMwstValue to gblGross

    Set the OnChange property of Kaufbetrag to:

     

    Set(
     gblGross,
     If(
     Len(Kaufbetrag)>0 && Len(MwstValue.Selected.Value)>0, 
     Kaufbetrag.Text * (MwstValue.Selected.Value/100+1) 
     )
    );

     

    Set the OnChange property of KaufbetragMwstValue to:

     

    Set(
     gblNet,
     If(
     Len(KaufbetragMwstValue) > 0 && Len(MwstValue.Selected.Value) > 0,
     KaufbetragMwstValue.Text / (MwstValue.Selected.Value / 100 + 1)
     )
    );
    

     

     

     

    Set the OnChange property of KaufbetragMwstValue to:

     

    Set(
     gblGross,
     If(
     Len(Kaufbetrag) > 0 && Len(MwstValue.Selected.Value) > 0,
     Kaufbetrag.Text * (MwstValue.Selected.Value / 100 + 1)
     )
    );
    Set(
     gblNet,
     If(
     Len(KaufbetragMwstValue) > 0 && Len(MwstValue.Selected.Value) > 0,
     KaufbetragMwstValue.Text / (MwstValue.Selected.Value / 100 + 1)
     )
    );
    

     

     

    This now changes when you change any of the values 🙂

    NetGross.gif

     

    Cheers,

    Sancho

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard