cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

DataCards Conditional Visible based on Multi Select Combo Box

Hi there,

 

I have an app where i have a combo box with multi-select  options. I want to show/hide datacards based on the options selected in the combo box. In the the "visible" control of the datacards i want to show/hide, i have the following formula:

 

If("Fluoro Recycling" in (WastDrop.Selected.Value),true,false)

 

This seems to work perfectly if I select a single option from the drop down list. The datacard appears and data can be entered. However, if i select multiple items from the drop down list, i will still only see a single data card (usually the last one selected).  

Any idea how i can get all the datacards selected to show up?

 

Thanks 🙂

 

Cym

1 ACCEPTED SOLUTION

Accepted Solutions

I recreated your use case. I have a CDS option set called 'Category (Accounts)' and the Items property of the combo box (ComboBox21 in my case) is set to 

Items = Choices('Category (Accounts)')

The option set has two values: Preferred Customer and Standard

 

I then have 2 labels (trying to mimic your data cards):

1. Label1 has

Text = "Preferred Customer" 

and

Visible = If(!IsBlank(LookUp(ComboBox21.SelectedItems, Text(Value) = "Preferred Customer")), true, false) 

2. Label2 has

Text = "Standard"

and

Visible = If(!IsBlank(LookUp(ComboBox21.SelectedItems, Text(Value) = "Standard")), true, false) 

 

This achieves what I think you set out to. Here is a working demo: 

ComboSelectedItems.gif

 

Let me know if this helps and if you want to know why I did it this way. 

 

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution.

Thanks!
Hardit Bhatia
https://thepoweraddict.com

 

View solution in original post

16 REPLIES 16
PowerAddict
Super User
Super User

Try

If("Fluoro Recycling" in (WastDrop.SelectedItems),true,false)

Let me know if this helps.

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution.

Thanks!
Hardit Bhatia
The Power Addict
https://thepoweraddict.com
Anonymous
Not applicable

Thanks @PowerAddict , but doesn't seem to work :

 

Error Says: Can't convert this data type. Ppower Apps can't convert this Text to a OptionSetValue (see attached).

Fair enough. I am assuming that "Fluro Cycling" is one of the options of an OptionSet. Is that correct?

If so, change the formula to:
If(OptionSet.'Fluoro Recycling' in (WastDrop.SelectedItems),true,false)

Let me know if this helps.

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution.

Thanks!
Hardit Bhatia
The Power Addict
https://thepoweraddict.com
Anonymous
Not applicable

Hi @PowerAddict.,

You are correct, that it is one of the options in a CDS option set. I've tried the formula you have proposed, but sadly still no luck!!  Any other ideas?

 

Thanks so much for your help!

 

My apologies, I am finally in front of a computer now. Can you please tell me what the Items property of the combo box is? Also, did you get an error with the above formula?

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution.

Thanks!
Hardit Bhatia
https://thepoweraddict.com
Anonymous
Not applicable

Don't apologise! I appreciate the help!

 

The items property of the combo box is set to: Choices('Waste Type')

 

Several errors:

Expected Operator.....

Unexpected characters. The formula contains 'ident' where 'fluoro recyling' is expected

 

 

I recreated your use case. I have a CDS option set called 'Category (Accounts)' and the Items property of the combo box (ComboBox21 in my case) is set to 

Items = Choices('Category (Accounts)')

The option set has two values: Preferred Customer and Standard

 

I then have 2 labels (trying to mimic your data cards):

1. Label1 has

Text = "Preferred Customer" 

and

Visible = If(!IsBlank(LookUp(ComboBox21.SelectedItems, Text(Value) = "Preferred Customer")), true, false) 

2. Label2 has

Text = "Standard"

and

Visible = If(!IsBlank(LookUp(ComboBox21.SelectedItems, Text(Value) = "Standard")), true, false) 

 

This achieves what I think you set out to. Here is a working demo: 

ComboSelectedItems.gif

 

Let me know if this helps and if you want to know why I did it this way. 

 

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution.

Thanks!
Hardit Bhatia
https://thepoweraddict.com

 

View solution in original post

Anonymous
Not applicable

You legend! That totally seems to have worked!  I'd love to understand that logic, as i don't think i could have figured it out.

Glad I could help!

Here's my approach as to how I figured it out:
1. So, option sets are like tables, so although the values in them seem like text, they are not really text.
2. With that understanding, I knew I had to reference the option set value in the If condition as OptionSet.Option1 and not "Option1".
3. Then the "in" condition was still not working because that, to the best of my understanding, is used to check if a string exists in a table or a collection. Since this isnt a string, it wont work.
4. Given this is just like a CDS entity, the way I use to check if a value exists in an entity is by using LookUp, I decided to use the same here and it worked!

It was a good refresher for me, so thank you for posting this!

Good luck with the rest of your app! Feel free to reach out in case of any questions!

Thanks,
Hardit Bhatia
The Power Addict
https://thepoweraddict.com

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,834)