cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
simms7400
Level 8

Filter ComboBox using another field?

Hi Folks -

 

I have a forum that has a data source of "rdPartnerAssets" and a ComBox that is populates with a certain source (Table.Column) based on a Radio button selection on my form.

 

However, I would like if I can filter ComboBox with another field from that source.  Each source has a SP column called "Portfolio_Status" and I'd like to return all value from the particular data source where "Portfolio_Status" <> Terminated.

 

My current formula is as follows:

If(Radio1.Selected.Value="Asset",RD_Portfolio_Compound_List.Alias,Radio1.Selected.Value="Investment",RD_Investment_List.Alias,Radio1.Selected.Value="Target",RD_Target_List.Alias)

I tried th filter function, but can't seem to get it to fire. Thanks!

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
egallis
Level 10

Re: Filter ComboBox using another field?

Great !

So... To clear the dropdown when you select another radio button (because the current ComboBox value may not be available in the newly selected datasource), we're going to use the Reset property of the ComboBox.

See the Reset property as a switch: when it goes from false to true it resets the control, clearing the user's selection.

To do so, just ADD the following code AFTER the actual code of your Radio1.OnChange:

Set(gloResetRadio1,true);
Set(gloResetRadio1,false)

And set your ComboBox.Reset to:

gloResetRadio1

And that's it !

View solution in original post

33 REPLIES 33
PowerApps Staff Mr-Dang-MSFT
PowerApps Staff

Re: Filter ComboBox using another field?

Formatted:

 

If(Radio1.Selected.Value="Asset",
    RD_Portfolio_Compound_List.Alias,
    
    Radio1.Selected.Value="Investment",
    RD_Investment_List.Alias,
    
    Radio1.Selected.Value="Target",
    RD_Target_List.Alias
)

 

 

If I'm understanding this right, you want to change which table's data appears here based on different values in the radio control.

 

Next you want to filter the content where the status is not terminated.

 

It could look like this:

 

If(Radio1.Selected.Value="Asset",
    Filter(RD_Portfolio_Compound_List,Not(Status="Terminated")).Alias,
    
    Radio1.Selected.Value="Investment",
    Filter(RD_Investment_List,Not(Status="Terminated")).Alias,
    
    Radio1.Selected.Value="Target",
    Filter(RD_Target_List,Not(Status="Terminated")).Alias
)

 

Reading from inside out. This filters the Portfolio Compound List to show only the records where the status is not terminated when the value selected in the radio is Asset, else it moves onto the other conditions. In each case, only show the Alias column.

 

As a rule of thumb, even though each table has the same structure, I generally avoid fitting different tables into the same control. That's just me nitpicking.

 

@Drrickryp , @timl who can see what function you can replace the If with to simplify the formula even more 🙂

 

simms7400
Level 8

Re: Filter ComboBox using another field?

@Mr-Dang-MSFT  Thank you!

 

However, my lists are still returning the "Terminated" elements from their respective tables.

Super User
Super User

Re: Filter ComboBox using another field?

@simms7400 - Just to confirm, I assume that you amended Mr Dang's condition to refer to your 'Portfolio_Status' field, rather than Status. Could you clarify the data type of 'Portfolio_Status'? Is it a Choice column? Do the data items in 'Portfolio_Status' include exactly the text 'Terminated'? (ie, with a capital T, no trailing spaces)

@Mr-Dang-MSFT - I see what you're trying to do - Switching this question into a quiz 😉

Community Support Team
Community Support Team

Re: Filter ComboBox using another field?

Hi @simms7400 

Do you want to filter the records not equal to “ Terminated"?

Could you tell me what is the data type of 'Portfolio_Status' column?

I assume that's a text column.

I recommend you try this formula:

 

If(Radio1.Selected.Value="Asset",

    Filter(RD_Portfolio_Compound_List,"Terminated" <> Status).Alias,

   

    Radio1.Selected.Value="Investment",

    Filter(RD_Investment_List,"Terminated" <> Status).Alias,

   

    Radio1.Selected.Value="Target",

    Filter(RD_Target_List,"Terminated" <> Status).Alias

)

 

 

 

 

Best regards,

Community Support Team _ Phoebe Liu

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
simms7400
Level 8

Re: Filter ComboBox using another field?

@v-yutliu-msft @timl 

 

Hi both - "Portfolio_Status" is a text field. 

 

I've tried the above formula and it is still returning records from the source table where "Portfolio_Status = "Terminated".

 

 

simms7400
Level 8

Re: Filter ComboBox using another field?

@v-yutliu-msft @timl  Hi Team - Sorry for the bother.

 

I was wondering if there was anything else I should be trying?  Thanks.

egallis
Level 10

Re: Filter ComboBox using another field?

Hi @simms7400,

Maybe your problem comes from the fact that a combo box items should (most of the time) be fed with the Choices() function in order to work properly.

So, assuming your Alias field is a choice or lookup field, this means that the above formulas given by @Mr-Dang-MSFT or @v-yutliu-msft should more likely look like this (by example for the Portfolio datasource):

Filter(
Choices(RD_Portfolio_Compound_List.Alias),
Not(
TrimEnds(Lower(Value))="terminated" // <- make sure "terminated" is all lowercase
)
)

Note the TrimEnds() and Lower() functions to make sure equality of string values won't be bothered by extra spaces or upper/lowercase letters.

 

Another idea would be to do the following:

  • in the OnChange event of your RadioButtons control, set local or global variable RD_List_DataSource with the right datasource according to the selection radio button
  • in the Items property of your combo box, set the following formula:
Filter(
    Choices(RD_List_DataSource.Alias),
    Not(
        TrimEnds(Lower(Value))="terminated" // <- make sure "terminated" is all lowercase
    )
)

Give us feedback once you'll have made some more tests...

Emmanuel

simms7400
Level 8

Re: Filter ComboBox using another field?

@egallis  Hi -

 

Thank you, but that doesn't validate.  Also, Alias isn't a choice column in the data sources.

 

 

simms7400
Level 8

Re: Filter ComboBox using another field?

Screen shot below:

chiucessss.png

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,812)