Skip to main content

Notifications

Power Apps - Building Power Apps
Unanswered

Setting a Dropdown default value using secondary field (not Value)

(0) ShareShare
ReportReport
Posted on by 22

Hello,

I have a dropdown that is created from two columns, like this:

Sort(ShowColumns(Filter([DataSource],[Column]=[FilteringCondition] ),"Description","Code"),Description,SortOrder.Ascending)

As a result, I have a dropdown with two fields available, "Description" and "Code". My Value property is set to Description field, so it shows all the descriptions from the list.

 

Similarly, the Default property is set to a variable that has a string that could be one of the descriptions possible, so it works fine and it positions the dropdown on the right element whenever the variable is set (if it is empty, shows the first element, as intended).

 

Question is: We can easily set Default by the Description content, but is there a way to Default it by the another column other than the one set in Value property? For instance, if I have a Code, can I use it to position the dropdown on the element that has that code, even though it is displaying Descriptions? Or are we "locked" to operations only on the Value-set column?

 

Thanks!

Categories:
  • OCJ Profile Picture
    OCJ 22 on at
    Re: Setting a Dropdown default value using secondary field (not Value)

     

    Thanks for the reply but that unfortunately does not solve, since I have duplicated descriptions and that's why searching for the code is relevant. For instance, if my dropdown is like this (Code / Description):

    001 / TextA
    002 / TextB
    003 / TextB
    004 / TextC

    If I use the code mentioned above, searching for code 003 will return description "TextB" from the data source, which will set the dropdown to the first occurrence (due to the lookup) which is code 002, the wrong code.

     

    What I need is that I can search directly the dropdown using code = 003 and position it on the right element so when later I use dropdown.SelectedText.code, for instance, I get the code 003 and not 002.

     

    Looks like that even though PowerApps allows you to have multiple columns in the dropdown, you're stuck with the one set on the Value property for searching.

     

  • LaurensM Profile Picture
    LaurensM 12,510 on at
    Re: Setting a Dropdown default value using secondary field (not Value)

    Hi @OCJ,

     

    That is certainly possible, but will require a slight adjustment to the Default property. As said, searching via the value field is very easy. You can simply save text to a string and use that as the default property.

     

    If we want to search via other fields, we will have to leverage a LookUp that returns the description of the record that matches our conditions:

    LookUp(DataSource, Description = variableName || Code = variableName).Description

     

    If this solves your question, would you be so kind as to accept it as a solution.

    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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,580

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,909

Leaderboard