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

Multiple conditions for autofill dropdown

Hi guys,

 

I am trying to do the following, I have an app where users need to select a product they want to order. Based on the product they need to give a yes or no option on two different fields. I want to get an automatic status update based on what the user does.

 

So for example, user picks product A and ticks yes, status becomes: No Actions.

 

This is the table I want to use

ProductA CompleteB CompleteStatus
AYesNoNo Actions
ANoNoUpload A
BNoYesNo Actions
BNoNoUpload B
A & BYesNoUpload B
A & BNoYesUpload A
A & BNoNoUpload A & B
A & BYesYesNo Actions

 

What would be the best and easiest way too implement this? 

 

Thanks for the help!

1 ACCEPTED SOLUTION

Accepted Solutions
Duhorothy
Frequent Visitor

Using three input controls and a collection, you can solve your issue. When the value of the ComboBox changes, perform a clear collect to keep track of which products are selected. I am collecting Product and Upload. The Upload column of this collection will be used to build the string in the status Label.

 

ComboBox (Products)
Items: ["Product A","Product B"]

OnChange: ClearCollect(Status, ForAll(Products.SelectedItems, {Product: Value, Upload: If(Value="Product A","A","B")}));Reset(OptionA);Reset(OptionB)

 

Toggle1 (OptionA)
OnCheck: Remove(Status, LookUp(Status,Product="Product A"))

OnUncheck: Collect(Status, {Product: "Product A", Upload:"A"})

 

Toggle2 (OptionB)

OnCheck: Remove(Status, LookUp(Status,Product="Product A"))

OnUncheck: Collect(Status, {Product: "Product A", Upload:"A"})

 

Label (Status) - I chose not to use a dropdown here. If that is a hard requirement you would need to define the choices, then select the appropriate choice using the same logic below

Text: If(CountRows(Status)=0, "No Actions", If(CountRows(Status)=2, "Upload "& Concat(Status, Upload, " & "), "Upload "&First(Status).Upload))

 

For fun, I displayed the toggles for Option A Complete and Option B Complete conditionally based on the Product Selection.

View solution in original post

5 REPLIES 5
RandyHayes
Super User
Super User

@Anonymous 

I have a feeling your example might be a bit too abstract for a definitive solution, but in your case I did this:

1) Created a ListBox with the following Items property ["A", "B"]

2) Created a Gallery with an Items property of ListBox1.SelectedItems

3) Put a CheckBox in the Gallery and set the Text property to: ThisItem.Value & " Complete"

4) Put a Label on the screen and set the Text property to:

With({lclUps:Filter(Split(Concat(Gallery1.AllItems, If(!Checkbox1.Value, Value & ",")), ","), !IsBlank(Result))},
    If(CountRows(lclUps)=0, "No Actions",
    "Upload " & Concat(lclUps, Result & If(!(Result=Last(lclUps).Result), " & ")))
)

 

This produces the exact results based on your description.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Duhorothy
Frequent Visitor

Using three input controls and a collection, you can solve your issue. When the value of the ComboBox changes, perform a clear collect to keep track of which products are selected. I am collecting Product and Upload. The Upload column of this collection will be used to build the string in the status Label.

 

ComboBox (Products)
Items: ["Product A","Product B"]

OnChange: ClearCollect(Status, ForAll(Products.SelectedItems, {Product: Value, Upload: If(Value="Product A","A","B")}));Reset(OptionA);Reset(OptionB)

 

Toggle1 (OptionA)
OnCheck: Remove(Status, LookUp(Status,Product="Product A"))

OnUncheck: Collect(Status, {Product: "Product A", Upload:"A"})

 

Toggle2 (OptionB)

OnCheck: Remove(Status, LookUp(Status,Product="Product A"))

OnUncheck: Collect(Status, {Product: "Product A", Upload:"A"})

 

Label (Status) - I chose not to use a dropdown here. If that is a hard requirement you would need to define the choices, then select the appropriate choice using the same logic below

Text: If(CountRows(Status)=0, "No Actions", If(CountRows(Status)=2, "Upload "& Concat(Status, Upload, " & "), "Upload "&First(Status).Upload))

 

For fun, I displayed the toggles for Option A Complete and Option B Complete conditionally based on the Product Selection.

Anonymous
Not applicable

Thank you for your reply, I will try it out later today! 

Let me know if this works for you!

@Anonymous 

Same here...

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,026)