web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How does the switch fu...
Power Apps
Answered

How does the switch function work?

(1) ShareShare
ReportReport
Posted on by 28

I'm confused with using switch function, please help.switch.png

Thank you!

Categories:
I have the same question (0)
  • Verified answer
    ANB Profile Picture
    7,250 Super User 2025 Season 2 on at

    Hi @zhuhaiyin Try this:

     

     

     

    Switch (
     rowNums,
     1,
     UpdateContext ({v1: 1}),
     2,
     UpdateContext ({v2: 1});
     UpdateContext ({v3: 3}),
     3,
     UpdateContext ({v4: 4});
     UpdateContext ({v5: 5});
     UpdateContext ({v6: 6}),
     4,
     UpdateContext ({v7: 7});
     UpdateContext ({v8: 8});
     UpdateContext ({v9: 9});
     UpdateContext ({V1O: 10}),
     5,
     UpdateContext ({v11: 11});
     UpdateContext ({v12: 12});
     UpdateContext ({v13: 13});
     UpdateContext ({V14: 14});
     UpdateContext ({V15: 15})
    )

     

     

    Basically, in the highlighted part, it should be comma, not semi-colon.

    ANB_0-1720783434341.png

     

    -----------------------------------------------------------------------------------------------------------------------------

    I hope this helps.

    Please click Accept as solution ✅ if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs up.👍

    Thanks,
    ANB


  • Selvarokith_B Profile Picture
    82 on at

    Hi , 

    Try this code 

     

    Switch(
    rowNums,
    1, UpdateContext({v1: 1}),
    2, UpdateContext({v2: 1, v3: 3}),
    3, UpdateContext({v4: 4, v5: 5, v6: 6}),
    4, UpdateContext({v7: 7, v8: 8, v9: 9, V1O: 10}),
    5, UpdateContext({v11: 7, v12: 8, v13: 9, V14: 10, V15: 15})
    )

     

    If you had further queries reply or Accept as solution.

     

    Thanks!

    @zhuhaiyin

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
Kalathiya Profile Picture

Kalathiya 408

#2
WarrenBelz Profile Picture

WarrenBelz 382 Most Valuable Professional

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 328 Super User 2025 Season 2

Last 30 days Overall leaderboard