cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
misc
Resolver II
Resolver II

If function to display certain dropdown choices based on previous selection

I have two dropdowns, dpd1 is 'Category' and dpd2 is 'Sub-category'. 

 

Under Categories I have 1, 2, 3, 4, 5 etc. Under sub-categories I have "a, b, c, d" etc.

 

However, I only want certain sub-categories to show up for certain categories, eg. dpd1 = "2", dpd2 = "a, b"; dpd1 = "4", dpd2 = "c, d"

 

Is there any way to do this? I have tried an IF statement using the same format as how you would populate a normal dropdown eg:

 

 

If(dpd1.SelectedText = "4", ["a", "b", "c"])

 

 but this isn't working. 

 

The Form is populated by a SharePoint list and the columns it's updating are Choice columns, if that helps at all.

 

Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions
misc
Resolver II
Resolver II

I figured this out, I had thought I'd done this the other day but tried again today and it worked so not sure what I did then. It was as simple as this:

 

If
(dpd1.Selected.Value = "1", ["a", "b", "c", "d"], 
dpd1.Selected.Value = "2", ["e", "f"],
dpd1.Selected.Value = "3", ["g", "h", "i", "j"])

 

View solution in original post

3 REPLIES 3
RandyHayes
Super User III
Super User III

@misc 
I am not sure if your values you cited are all made up values or if you are getting them from some place, but if you are making your own Items in dpd1, you can easily add this without any If's.

Example:  

Items property of dpd1 - 

 

Table(
    {Value:1, Subs:["a", "f"]},
    {Value:2, Subs:["a", "b"]},
    {Value:3, Subs:["b", "d"]},
    {Value:4, Subs:["c", "d"]}
)

 

Items property of dpd2 -

 

dpd1.Selected.Subs

 

 

Result:

dropdowns1.gif

I hope this is helpful for you.

 

EDIT: oh...and by the way - avoid using the SelectedText property, it is deprecated and should be avoided.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

Thanks for your reply, I've tried to do that and it doesn't want to work, giving me the red wiggly line error "Name isn't valid, identifier not recognised" on my first Value and the overall error "Expected Operator, we expect an operator such as +, * or & at this point in the formula".

 

The dropdowns are choice columns which are pulled from SharePoint, so the default Items of of dpd1 is:

 

 

 

Choices([@Incidents].Incident_x0020_Category)

 

 

 

Could that be why this fix doesn't work?


EDIT: Having played around more after your comment on SelectedText I can confirm I have managed to get it to half work eg. I can use the following to have dpd2 show the correct options for one of the choices from dpd1:

 

 

If(dpd1.Selected.Value = "1", ["a", "b", "c", "d"])

 

However when I try to expand it using that format and OR statements it breaks again eg:

 

 

If(dpd1.Selected.Value = "1", ["a", "b", "c", "d"]||dpd1.Selected.Value = "2", ["e", "f", "g"])

 

 

misc
Resolver II
Resolver II

I figured this out, I had thought I'd done this the other day but tried again today and it worked so not sure what I did then. It was as simple as this:

 

If
(dpd1.Selected.Value = "1", ["a", "b", "c", "d"], 
dpd1.Selected.Value = "2", ["e", "f"],
dpd1.Selected.Value = "3", ["g", "h", "i", "j"])

 

View solution in original post

Helpful resources

Announcements
User Groups Public Preview

Join us for our User Group Public Preview!

Power Apps User Groups are coming! Make sure you’re among the first to know when user groups go live for public preview.

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (56,979)