cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
mmattar
Level 8

How to reference a dropdown item

Hello,

 

If i have a dropdown consisiting of string items, ex: ["hi", "bye"], then i have a label that shows me if i have selected hi, If(dropdown.SelectedText.Value = "hi", true, false). This works, output will be true. But instead of hardcoding the string, can we reference the items in the dropdown as array indexes ? 

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: How to reference a dropdown item

@mmattar 

You would select the 2nd item like this.

 

If(
    Dropdown.SelectedText.Value= Last(FirstN(["hi","bye","wow","ohno"],2)).Value,
    true,
    false
);

 

And the 3rd item like this

 

If(
    Dropdown.SelectedText.Value= Last(FirstN(["hi","bye","wow","ohno"],3)).Value,
    true,
    false
);

 

And the 4th Item like this...

 

If(
    Dropdown.SelectedText.Value= Last(FirstN(["hi","bye","wow","ohno"],4)).Value,
    true,
    false
);

 

Let me know if you have further questions.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

4 REPLIES 4
Super User
Super User

Re: How to reference a dropdown item

@mmattar 

Yes, you can check to see if the dropdown equals the first value within the dropdown.  We can check for the 1st position Item using the FIRST function.  It's not an array index but it works!

 

If(
    Dropdown.SelectedText.Value= First(["hi","bye"]),
    true,
    false
);

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

 

 

mmattar
Level 8

Re: How to reference a dropdown item

how about if we want to see if the 2nd,3rd, or 4th item was selected ? 

Super User
Super User

Re: How to reference a dropdown item

@mmattar 

You would select the 2nd item like this.

 

If(
    Dropdown.SelectedText.Value= Last(FirstN(["hi","bye","wow","ohno"],2)).Value,
    true,
    false
);

 

And the 3rd item like this

 

If(
    Dropdown.SelectedText.Value= Last(FirstN(["hi","bye","wow","ohno"],3)).Value,
    true,
    false
);

 

And the 4th Item like this...

 

If(
    Dropdown.SelectedText.Value= Last(FirstN(["hi","bye","wow","ohno"],4)).Value,
    true,
    false
);

 

Let me know if you have further questions.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

Community Support Team
Community Support Team

Re: How to reference a dropdown item

Hi @mmattar ,

Could you please share a bit more about your scenario?

Do you want to reference the Items option within the Dropdown box as array index rather than hardcoding the string?

 

I have made a test on my side, pleae take a try with the following workaround:

1. Reference first item option:

If(dropdown.SelectedText.Value = Last(FirstN(["Option1", "Option2", "Option3", "Option4", ...], 1)).Value, true, false)

2. Reference second item option:

If(dropdown.SelectedText.Value = Last(FirstN(["Option1", "Option2", "Option3", "Option4", ...], 2)).Value, true, false)

3. Reference third item option:

If(dropdown.SelectedText.Value = Last(FirstN(["Option1", "Option2", "Option3", "Option4", ...], 3)).Value, true, false)

4. Reference forth item option:

If(dropdown.SelectedText.Value = Last(FirstN(["Option1", "Option2", "Option3", "Option4", ...], 4)).Value, true, false)

...

...

 

Please take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
thirdimage

Coming Soon: T-Shirt Design Contest

Keep your eyes open for our upcoming T-shirt design contest!

thirdimage

Power Apps Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

Top Solution Authors
Top Kudoed Authors
Users online (6,504)