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 value based...
Power Apps
Answered

How to set value based on gallery select

(0) ShareShare
ReportReport
Posted on by 202

Hi,

 

I have two galleries (gal1,gal2) on different screens gal 2 is an editable grid, in gal1 there's a field called ID I wanted to take the value of the selected field(ID) and populate in the Source ID field of gal2 but it should only add the values if a new field is created or it should take its default value 

 

I used this formula "ondefault" property in the gal2 source id field. 

If(
 defaultval,
 If(
 Value(sourceid) > 0,
 ThisItem.SourceId
 ),sourceid
)

Thanks in Advance

 

Regards,

Mahmood

Capture.PNG
Categories:
I have the same question (0)
  • v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @mahmoodhsaud ,

     

    I don't quite understand your needs.

     

    Could you provide some formulas/images or supplement your needs?

     

    Best Regards,
    Wearsky
    If my post helps, then please consider Accept it as the solution to help others. Thanks.

  • mahmoodhsaud Profile Picture
    202 on at

    Hi @v-xiaochen-msft 

     

    I have two screens, screen1 and screen2.  Each screen has a gallery on it, gallery1 and gallery2 respectively.

    Each gallery's items property is pointed towards the different data source, a SQL table1, and table2.

     

    In gallery1 onselect property, i have created a variable to store the value of selected rows (sourceid)

    Set(sourceid,Gallery1.Selected.Source_Id_Label1.Text);Navigate(Screen6_1,ScreenTransition.Fade);

     

    I have a button(addrow) on screen2 in which Onselect property has some function, used to add a row in the gallery 2

    Set(varGridEditable1, true );Patch('DAP.SourceItem',Defaults('DAP.SourceItem'),{SourceItemName:""});

     

    if the addrow button is clicked i need to set the value of source item id (textinput) of gallery2 to the variable sourceid (from gallery1) or by default the value should be ThisItem.SourceId

     

    The below formula i have used on the Sourceid default property is not working

    If(defaultval,If(Value(sourceid)>0,ThisItem.SourceId),sourceid)

     

    Regards,

    Mahmood

    Capture5.PNG
    Capture.PNG
    Capture2.PNG
  • Verified answer
    v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @mahmoodhsaud ,

     

    If you press the button and add a new item to table2, why don't you directly save the selected value in gallery1 to the item?

     

    For example:

    You could use this formula on your button control:

    Set(varGridEditable1, true );Patch('DAP.SourceItem',Defaults('DAP.SourceItem'),{SourceItemName:"",SourceId:Value(sourceid)});

     

    Then use this formula on Default property of your textinput control in gallery2:

    ThisItem.SourceId

     

    Does this meet your needs?

    Besides, I don’t know what 'defaultval' is.

     

    Best Regards,
    Wearsky
    If my post helps, then please consider Accept it as the solution to help others. Thanks.

     

     

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 July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 392 Most Valuable Professional

#2
11manish Profile Picture

11manish 136 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 109 Super User 2026 Season 2

Last 30 days Overall leaderboard