cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
New Member

How can I set the default value of a dropdown to be all items within it?

I am using a dropdown field for filtering purposes within a list. I have a multi choice dropdown list created by a split function, from previous selections, and I want to eliminate the user's ability to select items, and just keep the selection as all possible choices from the dropdown. Thanks for your help 🙂 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @egornau ,

Could you please show more details about the formula you typed within the DefaultSelectedItems property of the ComboBox?

 

Based on the needs that you mentioned, I think the Split function is in right direction.  I have made a test on my side, please take a try with the following workaround:

2.JPG

Set the Items property of the ComboBox to following:

Split(
      If('Dropdown1'.Visible, 'Dropdown1'.Selected.Name & "; ","") & If('Dropdown2'.Visible,'Dropdown2'.Selected.Name & "; ","") & If('Dropdown3'.Visible, 'Dropdown3'.Selected.Name & "; ","") & If('Dropdown4'.Visible,'Dropdown4'.Selected.Name & "; ", ""),
      "; "
)

Set the DefaultSelectedItems property of this ComboBox to following:

ForAll(
       Split(
            If('Dropdown1'.Visible, 'Dropdown1'.Selected.Name & "; ","") & If('Dropdown2'.Visible,'Dropdown2'.Selected.Name & "; ","") & If('Dropdown3'.Visible, 'Dropdown3'.Selected.Name & "; ","") & If('Dropdown4'.Visible,'Dropdown4'.Selected.Name & "; ", ""),
      "; "
      ),
      {
         Result: Result
      }
)

 

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Super User III
Super User III

@egornau 

To do this you would simply put the same code in the DefaultSelectedItems property as the Items property.

 

Example:


Items:

ComboBoxSample

 

DefaultSelectedItems:

ComboBoxSample

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Hi @mdevaney, thank you for your response. My Items property code is the below:

Split(If('Dropdown1'.Visible, 'Dropdown1'.Selected.Name & "; ","") & If('Dropdown2'.Visible,'Dropdown2'.Selected.Name & "; ","") & If('Dropdown3'.Visible, 'Dropdown3'.Selected.Name & "; ","") & If('Dropdown4'.Visible,'Dropdown4'.Selected.Name & "; ", ""),"; ")

 I tried putting this into DefaultSelectedItems property, but it still doesn't populate it automatically, any ideas?

@egornau 

One thing to note is if you've already changed the values manually in the ComboBox it won't show the default values anymore.  You'll have to reset it the ComboBox.

 

If that fails, try putting the result of your code into a collection instead.

ClearCollect(
    myComboBoxOptions,
    Split(If('Dropdown1'.Visible, 'Dropdown1'.Selected.Name & "; ","") & If('Dropdown2'.Visible,'Dropdown2'.Selected.Name & "; ","") & If('Dropdown3'.Visible, 'Dropdown3'.Selected.Name & "; ","") & If('Dropdown4'.Visible,'Dropdown4'.Selected.Name & "; ", ""),"; ")
)

 

Then use the same collection in the Items property and DefaultSelectedItems

myComboBoxOptions

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

@mdevaney 

 

Huh, I guess in my case ComboBox is not the right solution then, if the default values are only set on opening of the form, I need them to update conditionally based on output of other DropDowns, which may or may not be on the form, depending on another ComboBox. 

 

I have managed to output the desired info into a string, with the following code: 

If('Dropdown1'.Visible, 'Dropdown1'.Selected.Name & "; ","") & If('Dropdown2'.Visible,'Dropdown2'.Selected.Name & "; ","") & If('Dropdown3'.Visible, 'Dropdown3'.Selected.Name & "; ","") & If('Dropdown4'.Visible,'Dropdown4'.Selected.Name & "; ", "")

 

So the output is "Option 1; Option 2; Option 4", for example, but I want the SharePoint list users to be able to filter out, for example just to see Option 2 items, hence the idea was to use Split and then output as a ComboBox for easy grouping/filtering. Is there a better way to do this? 

 

Again, thanks for all your help.

Hi @egornau ,

Could you please show more details about the formula you typed within the DefaultSelectedItems property of the ComboBox?

 

Based on the needs that you mentioned, I think the Split function is in right direction.  I have made a test on my side, please take a try with the following workaround:

2.JPG

Set the Items property of the ComboBox to following:

Split(
      If('Dropdown1'.Visible, 'Dropdown1'.Selected.Name & "; ","") & If('Dropdown2'.Visible,'Dropdown2'.Selected.Name & "; ","") & If('Dropdown3'.Visible, 'Dropdown3'.Selected.Name & "; ","") & If('Dropdown4'.Visible,'Dropdown4'.Selected.Name & "; ", ""),
      "; "
)

Set the DefaultSelectedItems property of this ComboBox to following:

ForAll(
       Split(
            If('Dropdown1'.Visible, 'Dropdown1'.Selected.Name & "; ","") & If('Dropdown2'.Visible,'Dropdown2'.Selected.Name & "; ","") & If('Dropdown3'.Visible, 'Dropdown3'.Selected.Name & "; ","") & If('Dropdown4'.Visible,'Dropdown4'.Selected.Name & "; ", ""),
      "; "
      ),
      {
         Result: Result
      }
)

 

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (70,350)