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 / How to set variable to...
Power Apps
Answered

How to set variable to a datasource column?

(0) ShareShare
ReportReport
Posted on by 1,097

I have a datasource that is a sharepoint list.

In my datasource i have a column called "xtype" and "xtype2"

 

I want to to push a button and update a textinput field on my app so that the datasource to the textinput changes.

 

For example

If user press button1 it sets textinput1 to have xtype in it´s Text option.

If user press button2 it sets textinput1 to have xtype2 in it´s Text option.

 

I have tried setting a variable on the Onselect on each button.

Likse this:

Set(buttonvar;xtype)

Set(buttonvar;xtype2)

 

Then put buttonvar in the textinput1 field

But i get error that xtype and xtype2 does not exist.

But they do...

 

What am i doing wrong?

Categories:
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Oskarkuus 

    Firstly, I am assuming you are working in an EditForm and thus on just one record. AND, that your button is within your Form.  This response is predicated on that assumption.

    What you can do is adjust your formulas to the following (on their respective buttons):

    Set(buttonvar; ThisItem.xtype)
    Set(buttonvar; ThisItem.xtype2)

    And, of course, the default value for your textinput would be buttonvar.

     

    If the above assumptions are not the case, then post back and we can punt at another option.

  • Oskarkuus Profile Picture
    1,097 on at

    I tried those codes but they do not work.

     

    I get the same error.

     

    I am working in an gallery.

    I want to change the gallery labels when i press a button outside of the gallery.

    so if i press button1 set textinput1 to xtype (column)

    if i press button2 set textinput1 to xtype2(column)

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Oskarkuus 

    Let me see if I understand you properly...

    You have a Gallery - not an EditForm.  Outside of the Gallery you have a 2 Buttons.  One (let's call) "xtype" and the other "xtype2".  If the user presses "xtype" you want the values in the textinput controls that you have in your Gallery to all change to reflect the xtype column of the item in the gallery.  If the user presses "xtype2" you want to have all the textinput controls in the gallery change to reflect the xtype2 column of the item.

     

    If that is the case, then you can take this approach:

    On the OnSelect of the xtype button, set this formula :  UpdateContext({showXtype2: false})

    On the OnSelect of the xtype2 button, set this formula:  UpdateContext({showXtype2: true})

    On the TextInput control in your Gallery, set the Default property to this formula:  If(showXtype2, ThisItem.xtype2, ThisItem.xtype)

     

    That will give you what I described above.  

    Let's see how that works for you.

     

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 411 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 338

#3
WarrenBelz Profile Picture

WarrenBelz 256 Most Valuable Professional

Last 30 days Overall leaderboard