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

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

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
Highlighted
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!
Highlighted

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"])

 

 

Highlighted
Resolver I
Resolver I

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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (7,654)