cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
MikeAnderson
Level: Powered On

Combo Box has no value formula issue

Hello,

 

I have two cascading combo boxes. I tried the following formula to check if Combo Box 1 doesn't have a value so I can disable the 2nd combo box (force user to choose from the first combo box).

If(CategoryCboBox.Selected.Description = "", SubCategoryCboBox.DisplayMode.View, Filter('[dbo].[EMCM]', udCategoryGroup = CategoryCboBox.Selected.Description))

All I get is an error saying there is an issue with the If statement, but no clues as to what.  Any thoughts?

1.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Combo Box has no value formula issue

Hm. Blank() values, empty strings (""), and " " can sometimes be problematic. 

First, ensure that a "blank" value in your dropdown is indeed equal to "". 

Add a temp debugging label and set its Text Property to:

If(CategoryCboBox.Selected.Description = "", "yay", "nay")

You might be surprised to see "nay". 

Also try:

If(IsBlank(CategoryCboBox.Selected.Description), "yay", "nay")

 

Aha, I also see you have the wrong number of arguments in your If() statement.

 

You're saying:

* CONDITION 1: IF combobox1 = ""

* THEN: make combobox2's Visible Property view only (<--I'm not sure you can do this without a variable)

* CONDITION 2: Filter(xyz)

* THEN: no argument

You can glean some valuable insights by looking at the If() Intellisense.

* After you enter If(condition1 = xzy,      look at the IntelliSense directly above the function bar. It will say "true_value"

* Enter another statement "ya",         the IntelliSense will say "else_value" BUT when you put in a third condition it will change to "true_value" again because it knows you have a multi-condition IF statement. 

If the goal is to just make combobox2 view only, then try:

  1. Make sure combobox1 truly = "" (or IsBlank) when the null value is selected
  2. Based on your findings there, set the Visible Property of combobox2 to:
    1. If(combobox1.Selected.Description = "", DisplayMode.View, DisplayMode.Edit) // or
      If(IsBlank(combobox1.Selected.Description), DisplayMode.View, DisplayMode.Edit

Pretty long-winded! 

Hope it helps!

6 REPLIES 6
Super User
Super User

Re: Combo Box has no value formula issue

Hi @MikeAnderson ,

 

There is a subtle trick to the "red squigglies". Slowly move your cursor along the IF statement in question, pausing before and after each "," and "." 

You'll see the message change to somthing more useful.

If you look reeeeeeallly close, you can see the Filter() part of your statement is "double red". This indicates (to the trained eye Smiley Happy )the problem is likely there. 

Good luck!

MikeAnderson
Level: Powered On

Re: Combo Box has no value formula issue

That helped, thank you!  Based on the error, it seems I can't filter my combo box from an If statement?  The filter statement works on its own, as it was working and then I tried to wrap this If statement around it.

 

1.png

Any thoughts on how I can disable the combo box 2 if no value is selected in combo box 1.  And if a value is selected in combo box 1, enable combo box 2 and then pass the filter value down to combo box 2?  This seems like it should be easy.

Super User
Super User

Re: Combo Box has no value formula issue

Hm. Blank() values, empty strings (""), and " " can sometimes be problematic. 

First, ensure that a "blank" value in your dropdown is indeed equal to "". 

Add a temp debugging label and set its Text Property to:

If(CategoryCboBox.Selected.Description = "", "yay", "nay")

You might be surprised to see "nay". 

Also try:

If(IsBlank(CategoryCboBox.Selected.Description), "yay", "nay")

 

Aha, I also see you have the wrong number of arguments in your If() statement.

 

You're saying:

* CONDITION 1: IF combobox1 = ""

* THEN: make combobox2's Visible Property view only (<--I'm not sure you can do this without a variable)

* CONDITION 2: Filter(xyz)

* THEN: no argument

You can glean some valuable insights by looking at the If() Intellisense.

* After you enter If(condition1 = xzy,      look at the IntelliSense directly above the function bar. It will say "true_value"

* Enter another statement "ya",         the IntelliSense will say "else_value" BUT when you put in a third condition it will change to "true_value" again because it knows you have a multi-condition IF statement. 

If the goal is to just make combobox2 view only, then try:

  1. Make sure combobox1 truly = "" (or IsBlank) when the null value is selected
  2. Based on your findings there, set the Visible Property of combobox2 to:
    1. If(combobox1.Selected.Description = "", DisplayMode.View, DisplayMode.Edit) // or
      If(IsBlank(combobox1.Selected.Description), DisplayMode.View, DisplayMode.Edit

Pretty long-winded! 

Hope it helps!

MikeAnderson
Level: Powered On

Re: Combo Box has no value formula issue

Thanks for the reply! I'll test this out in the morning.

Based on https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-if and the example of:

If( Slider1.Value > 1000, "Result1", "Result2" )

I was of the understanding I could use the evaluation of If combo box1 is empty then set combo box 2 to view only else filter combo box 2. Ignoring for the moment I don't reenable combo box 2, I thought this would be the correct syntax.

I'll test this more in the AM thanks again for your input!
Super User
Super User

Re: Combo Box has no value formula issue

Right on. Yep, correct logic. Just split it up a bit and place it on the Visible Property of combobox2.
MikeAnderson
Level: Powered On

Re: Combo Box has no value formula issue

But that's at the crux of my issue, the logic doesn't work right as shown in the screen shot.  It doesn't like the Filter statement in the Else part of the statement.

 

The filter statement by itself works:

1.png

 

But wrapped in an IF statement, it doesn't:

1.png

 

Ok, I finally figured it out.  And I hope this helps someone else!

 

I placed the following logic for the 2nd Combo Box (Sub-Category) in the DisplayMode method:

If(IsBlank(CategoryCboBox.Selected.Description), DisplayMode.Disabled, DisplayMode.Edit)

1.png

 

It then works as I was expecting:

1.png

 

Select a value in the first combo box, which then enables the second combo box.

1.png

 

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Users Online
Currently online: 45 members 4,898 guests
Please welcome our newest community members: