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 Pages / Auto populate first dr...
Power Pages
Answered

Auto populate first dropdown value in the second dropdown in a customized gallery

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi, 
I need a help with my powerapps Gallery, I have a customized gallery named "TripRecord" which also has 4 input fields, '+' and 'X' icons to add and delete a record.

input1- from location: dropdown, input2- To location: dropdown, input3- from date: datepicker, input4- to date: datepicker

 

what I want the gallery to do as below,

ex: consider the first record items is selected as below

fromdropdown1: Canada   Todropdown1: Mexico 

Fromdate1: 1/01/2020        todate1: 2/01/2020

 

and in the second record of the gallery, I want the Fromdropdown2 to get the value from Todropdown1 to be auto populated as below and let the user choose the values for the rest of the fields.

Fromdropdown2: Mexico  (auto populate Mexico)   todropdown2

Fromdate2:        todate2

 

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

    Hi @Anonymous :

    I've made a test for your reference:

    My data source-TripRecord:

    • ID-number
    • Input1-Text
    • Input2-Text
    • Input3-Date
    • Input4-Date
    ClearCollect(TripRecord,{Input1:"",Input2:"",Input3:Today(),Input4:Today()})

    1\Add a gallery and set it's Items proeprty to:

    TripRecord

    2\Add two drop down controls into this gallery(fromdropdown/Todropdown)

    Set fromdropdown:

    Items

    ["","Canada","Mexico","US","UK"]

    OnChange

    Patch(TripRecord,ThisItem,{Input1:fromdropdown.SelectedText.Value})

    Default

    ThisItem.Input1

    Set Todropdown:

    Items

     

    ["","Canada","Mexico","US","UK"]

     

    OnChange

     

    Patch(TripRecord,ThisItem,{Input2:Todropdown.SelectedText.Value})

     

    Default

     

    ThisItem.Input2

     

    3\Add two date picker controls into this gallery(Fromdate/Todate)

    Set Fromdate

    OnChange

    Patch(TripRecord,ThisItem,{Input3:Fromdate.SelectedDate})

    DefaultDate

    ThisItem.Input3

    Set Todate

    OnChange

     

    Patch(TripRecord,ThisItem,{Input4:todate.SelectedDate})

     

    DefaultDate

     

    ThisItem.Input4

    4\Add an "Add" icon and an "Rubbish-bin" icon

    Add icon-OnSelect

    Patch(TripRecord,Defaults(TripRecord),{ID:CountRows(TripRecord)+1,Input1:Todropdown.SelectedText.Value})

    Rubbish-bin icon-OnSelect

    Remove(TripRecord,ThisItem)

    Best Regards,

    Bof

     

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hello Bof, 

     

    Thankyou very much for your response, i followed your steps, but unfortunately it did not give me the result i wanted. i want the to country to be auto populated as from country in the second entry as shown in the below image.

    ZenHen_0-1600254696487.png

    @v-bofeng-msft 

  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous :

    I've made a test but it worked well.

    20.gif

    Please try adding a unique identifier "ID" to TripRecord.For Example:

    ClearCollect(TripRecord,{Input1:"",Input2:"",Input3:Today(),Input4:Today()})

    1\Add a gallery and set it's Items proeprty to(Sort the items displayed in the Gallery in ascending order😞

    Sort(TripRecord,ID)

    2\Add two drop down controls into this gallery(fromdropdown/Todropdown)

    Set fromdropdown:

    Items

    ["","Canada","Mexico","US","UK"]

    OnChange

    Patch(TripRecord,ThisItem,{Input1:fromdropdown.SelectedText.Value})

    Default

    ThisItem.Input1

    Set Todropdown:

    Items

    ["","Canada","Mexico","US","UK"]

    OnChange

    Patch(TripRecord,ThisItem,{Input2:Todropdown.SelectedText.Value})

    Default

    ThisItem.Input2

    3\Add two date picker controls into this gallery(Fromdate/Todate)

    Set Fromdate

    OnChange

    Patch(TripRecord,ThisItem,{Input3:Fromdate.SelectedDate})

    DefaultDate

    ThisItem.Input3

    Set Todate

    OnChange

    Patch(TripRecord,ThisItem,{Input4:todate.SelectedDate})

    DefaultDate

    ThisItem.Input4

    4\Add an "Add" icon and an "Rubbish-bin" icon

    Add icon-OnSelect

    Patch(TripRecord,Defaults(TripRecord),{ID:Last(Sort(TripRecord,ID)).ID+1,Input1:Todropdown.SelectedText.Value})

    Rubbish-bin icon-OnSelect

    Remove(TripRecord,ThisItem)

    The principle of my solution is:
    1: When adding a new item: Use the Todropdown.SelectedText.Value of the current record as the value of the Input1 field of the new record.
    2: When displayed, the default value of the To drop-down box of the new item is the value of Input1, so it will display the Todropdown.SelectedText.Value of the previous record by default

    Best Regards,

    Bof

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    That worked Bof, Thats a million. @v-bofeng-msft 

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Pages

#1
Lucas001 Profile Picture

Lucas001 21 Super User 2026 Season 1

#2
CN-06091549-0 Profile Picture

CN-06091549-0 18

#3
oliver.rodrigues Profile Picture

oliver.rodrigues 17 Most Valuable Professional

Last 30 days Overall leaderboard