Skip to main content

Notifications

Community site session details

Community site session details

Session Id : SOsJv0eNEhZnZiPrsuxA4D
Power Apps - Building Power Apps
Answered

Get last selection with ComboBox

Like (0) ShareShare
ReportReport
Posted on 18 Mar 2021 16:26:12 by 104

Hello the Community,

I would like get the last user selection of a combobox.

For example, in my Combobox, I have 3 items ["item1", "item2", "item3].
Firstly, the user selects "item1" and after "item2". Now, here I want display in a TextBox : "Your last selection is item1" (with a variable for example)


It works with a Dropdown and its onSelect property, but I need features of Combobox (mostly isSearchable and reset). So I can not use a Dropdown.


Could you help me ?

 

Bye.


Charlie.

Categories:
  • Charlie Profile Picture
    104 on 19 Mar 2021 at 06:39:18
    Re: Get last selection with ComboBox

    Thank a lot for your help.

    I understand the way to do it. 

     

    Bye.

  • Verified answer
    Spamrancher Profile Picture
    345 on 18 Mar 2021 at 21:36:27
    Re: Get last selection with ComboBox

    I'm using the ComboBoxSample data that is structured like the image below. You'll need to adapt the code to fit the Items in your ComboBox.

    Spamrancher_0-1616103239461.png

     

    In the OnChange property of your ComboBox, enter:

     

    Collect(boxHistory, {value: Self.Selected, index: Last(boxHistory).index + 1})

     

    In your label/textbox, enter this for the Text property, where "Value1" is the field you want to display from the ComboBox.

     

    LookUp(boxHistory, index = Last(boxHistory).index - 1).value.Value1

     

     

    Result:

    Spamrancher_1-1616103458314.png

     

    Be sure to clear the collection at the appropriate time so it doesn't retain the history past where you want it to.

  • Charlie Profile Picture
    104 on 18 Mar 2021 at 16:39:03
    Re: Get last selection with ComboBox

    Hello,

     

    Unfortunately, this update the lastSelected variable with the new value of my ComboBox, so like Set(lastSelected, Self.Selected.<Value>)

  • Spamrancher Profile Picture
    345 on 18 Mar 2021 at 16:31:53
    Re: Get last selection with ComboBox

    In the OnChange of ComboBox, try UpdateContext({lastSelected: Self.Selected.<Value>}), where <Value> is the item value you want to capture. Then your label/textbox could be "Your last selection is " & lastSelected.

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,645 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,997 Most Valuable Professional

Leaderboard