web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Dataverse choice colum...
Power Apps
Unanswered

Dataverse choice column to dropdown

(0) ShareShare
ReportReport
Posted on by 71

Hi all,

 

I'm trying to create dropdowns from choice columns in a dataverse table that will filter a gallery. I also need to add "All" as an option for the dropdowns.

 

I started with this in the OnVisible property of the screen:

 

ClearCollect(CatList,Choices('Shoe Inventory Finals'.ProductCategory));
Collect(CatList,{Result: "All"});
ClearCollect(ColorList,Choices('Shoe Inventory Finals'.Color));
Collect(ColorList,{Result: "All"})
 
And then I wanted to use the collections created as items in the dropdowns. So my dropdown items would be:
 
Choices(CatList) and Choices(ColorList)
 
Then I want to be able to filter my gallery based on these dropdowns. I wrote this If statement:
 
If(
    drpCategory.Selected.Value = "All", If(drpColor.Selected.Value = "All",'Shoe Inventory Finals',
Filter(
    'Shoe Inventory Finals',
   ProductCategory = drpCategory.Selected.Value &&
    Color = drpColor.Selected.Value)))
 
None of it is working, and I ran into issues when I tried to use the Text function in the dropdowns because I need other data in the data source to stay formatted as numbers.
Categories:
I have the same question (0)
  • DavidZoon Profile Picture
    738 Most Valuable Professional on at

    Hello,

    To my knowledge, it is not possible to add a personalized value to a Dataverse choice list on the fly. The reason is that it is a complex data type, whereas a Sharepoint choice column can easily be broken down into Value / Id in Power Apps.

    rather than trying to add an "All" option, I generally provide an escape from my filter: if my combobox is empty, then we display all the results.

     

    We can make this type of filter with the following formula:

     

    Filter('Table name' , 'Choice column 1' = ComboBox.Selected.Value || IsEmpty(ComboBox.SelectedItems))

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily.

  • arinard Profile Picture
    71 on at

    Hi David,

     

    Thank you for your response. Will that formula work for a dropdown instead of a combo box? I tried this, but I'm getting an error:

     

    Filter('Shoe Inventory Finals',Color=drpColor.Selected.Value||IsEmpty(drpColor.Selected.Value))
     
    I'm getting an invalid argument type error in the last argument.
  • Verified answer
    Ami K Profile Picture
    15,674 Super User 2024 Season 1 on at

    @arinard - one comment here after advising you on your other post. 

     

    https://powerusers.microsoft.com/t5/Building-Power-Apps/If-statement-with-multiple-conditions/td-p/2673865 

     

    A data source returns a table. And a Choice field also returns a table. Irrespective of where it comes from, a table is still a table, and specific attributes can be modified in the same way as any other control which returns a table.

     

    If you modify the Choices field in the Dropdown items property to return a custom value, the items in that Dropdown will no longer return a valid record. However, so long as you're not using the modified Dropdown to save the selected choice to your data source, and you simply want to use the modified Dropdown for filtering the Local Choice field in your Dataverse table, this is possible.

     

    However, you will need to ensure the Items property in the Dropdown, and the Choice field in your data source, share the same data type to produce a valid Filter. In your scenario, we want the Items in the Dropdown, and the Items in your data source, to both return a text data type rather than a record data type.

     

    https://learn.microsoft.com/en-us/power-platform/power-fx/data-types 

     

    You will need to use the AddColumns function to "transform" or "shape" the Choices field in your data source as a duplicate column, but as a text data type, rather than a record data type. You will need to apply this function in both the Items property of the Dropdown control, and in the Items property of the Gallery.

     

    In the Items property of your Dropdown control, use:

     

    Ungroup(
     Table(
     {DropdownOptions: ["All"]},
     {
     DropdownOptions: RenameColumns(
     ShowColumns(
     AddColumns(
     Choices('Shoe Inventory Finals'.Color),
     "_ChoiceText",
     Text(Value)
     ),
     "_ChoiceText"
     ),
     "_ChoiceText",
     "Value"
     )
     }
     ),
     "DropdownOptions"
    )

     

    In the Items property of your Gallery, use:

     

    Filter(
     AddColumns(
     'Shoe Inventory Finals',
     "_ChoiceText",
     Text(Color)
     ),
     Len(drpColor.Selected.Value) = 0 || drpColor.Selected.Value = "All" || _ChoiceText = drpColor.Selected.Value
    )

     

     

    Now that both the selected item in your dropdown, and the field you want to filter on are the same data type (text), this will produce a valid filter.

     

    Please note however, that the UnGroup and AddColumns functions are not delegable.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 793 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 333 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard