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 / convert value dependin...
Power Apps
Answered

convert value depending on one field

(0) ShareShare
ReportReport
Posted on by 136

Hello Power apps Community,

I have an issue with the power apps while converting the values depending on a particular field

PrudhviL_0-1685542042096.png

In the above image have 2 units N and Lbs. what ever the value I enter in N should be converted into Lb and Vice versa. 

 

I took the Sample 1 of Lb (Pounds) and used the below formula in the image for the conversion and worked fine. 

PrudhviL_1-1685543021636.png

But when i try to do it Vice versa it is giving me error as mentioned in below image 

PrudhviL_2-1685543240307.png



Can anyone please help me in this issue or show me a work around to have values converted vice versa (From N to Lb & Lb to N)
Thanks in Advance.

Categories:
  • Verified answer
    CU22081303-0 Profile Picture
    150 on at

    Hi, I've ran into similar issues while converting measurements from Metric to Imperial or vice versa. Your issue here is that you are creating a circular reference. I suggest using two variables: one to track which field is currently the primary one, and another to hold the value of that primary field so we can access it without making Power Apps upset because of the circular reference. I tried to emulate your setup as best as possible.

     

    DataCardValue 4

    Default:

    If(primaryInput = "DataCardValue7",
    primaryInputValue * 4.423451,
    0
    )

    OnChange:

    Set('primaryInput', "DataCardValue4");
    Set('primaryInputValue', Value(DataCardValue4.Text));

     

     

    DataCardValue7

    Default:

    If(primaryInput = "DataCardValue4",
    primaryInputValue * 0.224808942443,
    0
    )

    OnChange:

    Set('primaryInput', "DataCardValue7");
    Set('primaryInputValue', Value(DataCardValue7.Text));

     

    Both components' OnChange functions will set the primaryInput variable to its own name, and store its value in the primaryInputValue variable.

     

    Both inputs will check if they are the primaryInput. If they are, they default to 0 like normal. If the other field is the primary, it will calculate its own value with what is stored in the variable (the other field's value) and do the appropriate calculation on it.

     

    This is a pain if doing many fields this way, as each pair of variables would need to be uniquely named. Also use caution if renaming the components because hardcoded component names. This also behaves strangely when entering a value that changes which is the primary field: you must input the number twice because the first time you enter it, it defaults itself to 0. Not ideal, but usable.

     

    TrekW_0-1685550407157.png

     

    TrekW_1-1685550529584.png

     

    I hope this helps you!

  • PrudhviL Profile Picture
    136 on at

    Hi @TrekW 

    Thank you for your response, It was an amazing solution and it worked out great to me. But yes as you said it is bit overwhelming for more columns in this 😅

     

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 352 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 323

#3
Mohsin Ali Profile Picture

Mohsin Ali 226

Last 30 days Overall leaderboard