cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Resolver I
Resolver I

Referencing combobox selecteditems in If statement

Hi all

 

I'm trying to set the visibility on a data table column with an If statement based on what is selected in a combobox.

The following seemed logical, but doesn't work, and throws up a warning:

 

IF_statement.JPG

 

 

 

IF_statement_1_play.JPG

Oddly, it will work if I add an Or operator and second If statement referencing another combobox (with the true and else values of the second IF statement reversed):

IF_statement_2.JPG

IF_statement_2_play.JPG

 

In case you're wondering, I have checked that I'm referencing the comboboxes the right way around 😉

 

Any ideas?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Dual Super User III
Dual Super User III

Re: Referencing combobox selecteditems in If statement

Hey @Caroline 

 

Have you changed the formula from what is shown in the first screenshot to:

If("Withdrawn learners" in FilterDropdown2_ReportsScrn.SelectedItems.Value,true,false)

This should work because FilterDropdown2_ReportsScrn.SelectedItems.Value returns a one-column list of all the selected items. Make sure that Value is the correct column to get these values.

 

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

10 REPLIES 10
Highlighted
Dual Super User III
Dual Super User III

Re: Referencing combobox selecteditems in If statement

Hi @Caroline 

 

You can set the Visible property of the column in the Data Table as:

If("Withdrawn learners" in FilterDropdown2_ReportsScrn.SelectedItems.Value,true,false)

 

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Highlighted
Community Support
Community Support

Re: Referencing combobox selecteditems in If statement

Hi @Caroline ,

Is this your original formula?

If(IsMatch(Concat(....),"...",conatins),"Withdrawn learners",true,false)

Could you describe the meaning of the red part?

The syntax of if statement should be like: If(formula,result1,result2)

While in your formula there has three results.

Please try this formula:

If(IsMatch(Concat(....),"...",conatins),true,false)

Here's a doc about if statement for your reference:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-if

 

 

 

Best regards,

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.
Highlighted
Resolver I
Resolver I

Re: Referencing combobox selecteditems in If statement

@yashag2255 thanks for the suggestion. That was my first go-to, but it only picks up the last item selected in the combobox.

 

combobox.JPG

Highlighted
Resolver I
Resolver I

Re: Referencing combobox selecteditems in If statement

@v-yutliu-msft thanks for looking at it. The "Withdrawn learners" is part of the syntax for the IsMatch statement.

As a simple If statement didn't get the desired result, I was trying to concat the combo box selected items, look for "Withdrawn learners" in the concatenation and return True/False, then set visible to True if IsMatch is True.

I'm thinking it's having the Concat statement nested in IsMatch that's the issue, any ideas?

Highlighted
Dual Super User III
Dual Super User III

Re: Referencing combobox selecteditems in If statement

Hey @Caroline 

 

Can you please share more details about what do you mean when you say it only pick the last element? Are you trying to retrieve this?

Based on the current expression, it will look for "Withdrawn learners" in all the selected Items. If there is a deviation, please share more details about the configuration of the combobox control, so that we might be able to help you better.

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Highlighted
Resolver I
Resolver I

Re: Referencing combobox selecteditems in If statement

Hi @yashag2255 

What I'm meaning is that it ignores all selected items except for the last one. In the screen shot on my last post, you can see that 'withdrawn learners' and 'email address' have been selected, but the 'withdrawn learners' column isn't visible in the table. 

If they are selected the other way around, with 'withdrawn learners' as the last option selected, the column would be visible.

 

As I'll be setting the visibility of several columns with the same formula, I need it to find the phrase anywhere in the selecteditems.

 

What do you need on the combobox configuration that would help?

Highlighted
Dual Super User III
Dual Super User III

Re: Referencing combobox selecteditems in If statement

Hi @Caroline 

 

The reason I wanted to know about the combobox configuration is to make sure that we are referencing to the correct column here.

Can you please confiem if you have used Combobox1.SelectedItems.Value instead of Combobox1.Selected.Value?

Expression:
If("Withdrawn learners" in FilterDropdown2_ReportsScrn.SelectedItems.Value,true,false)

 

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Highlighted
Resolver I
Resolver I

Re: Referencing combobox selecteditems in If statement

@yashag2255 Yes, definitely using selecteditems.

 

You can see the full formula in my initial post.

 

Cheers

Highlighted
Dual Super User III
Dual Super User III

Re: Referencing combobox selecteditems in If statement

Hey @Caroline 

 

Have you changed the formula from what is shown in the first screenshot to:

If("Withdrawn learners" in FilterDropdown2_ReportsScrn.SelectedItems.Value,true,false)

This should work because FilterDropdown2_ReportsScrn.SelectedItems.Value returns a one-column list of all the selected items. Make sure that Value is the correct column to get these values.

 

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (3,999)