Skip to main content

Notifications

Power Apps - Building Power Apps
Suggested answer

Function of If statement for dropdown based on the previous dropdown selection

(0) ShareShare
ReportReport
Posted on by 4
Hi Community!
 
I have to build two dropdown of which if the first dropdown is "A" then the second dropdown will set as "E"
 
The list of the first drop down:
A
B
C
D
 
The second dropdown based on selection :
A = E
B = F
C = G
D = H
 
How do we do this? and where to set it?
Categories:
  • Suggested answer
    Ravindra Jadhav Profile Picture
    Ravindra Jadhav 240 on at
    Function of If statement for dropdown based on the previous dropdown selection

    using the Switch function in Power Fx, We Can Achive this

    1. Set the Items property of the second dropdown based on the first dropdown selection:

    In the OnChange property of the first dropdown (let’s call it Dropdown1):

    Switch(
    Dropdown1.Selected.Value,
    "A", "E",
    "B", "F",
    "C", "G",
    "D", "H",
    ""
    )
    
    Set the Items property of the second dropdown (let’s call it Dropdown2) to this formula:
    
    Table({Value: Switch(Dropdown1.Selected.Value, "A", "E", "B", "F", "C", "G", "D", "H")})
     
    Please Closed the Question, Mark it Solved 
     
    If my answer helped resolve your issue, please consider marking it as solved to assist others facing the same problem. Additionally, giving it a like would be greatly appreciated and motivates us to keep helping
     
    Thank You
    Ravindra Jadhav
  • NH-09100837-0 Profile Picture
    NH-09100837-0 4 on at
    Function of If statement for dropdown based on the previous dropdown selection
    Hi @nandit,
     
    It throw me an error. I might look noob here but may I know where do you put the switch statement? I dont find DefaultSelectedItems property. 
     
  • Suggested answer
    Nandit Profile Picture
    Nandit 1,545 on at
    Function of If statement for dropdown based on the previous dropdown selection
     
    To achieve this, you can make use of the Switch statement in the DefaultSelectedItems property of the second dropdown. 
     
    Items property of the First Dropdown:
    ["A", "B", "C", "D"]
    Items property of the second Dropdown:
    ["E", "F", "G", "H"]
     
    Here is the DefaultSelectedItems property of the Second Dropdown:
    Switch(
        firstdrpdown.Selected.Value,
        "A",
        ["E"],
        "B",
        ["F"],
        "C",
        ["G"],
        "D",
        ["H"]
    )
    Here's how it looks:
     
    Hope this helps. 
     
    Kind regards, 
    Nandit

    If this answers your query, please mark this response as the answer.
    If its helpful, please leave a like. Thanks!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,434

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,722

Leaderboard