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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to set many variab...
Power Apps
Answered

How to set many variables in switch()

(0) ShareShare
ReportReport
Posted on by 517

Hey,

I'm trying to set many variables in switch(). Somehow It doesn't work. See below:

OnStart :

Set(_dateToday, Today());

Switch(
Weekday(_dateToday),
2, Set(showMonday, true ) ; Set(showTuesday, false) ; Set(showWednesday, false),
3, Set(showMonday, false ) ; Set(showTuesday, true) ; Set(showWednesday, false),
4, Set(showMonday, false ) ; Set(showTuesday, false) ; Set(showWednesday, true)
)

Do you have any idea? Do I miss something?

Thanks.

Categories:
I have the same question (0)
  • NandiniBhagya20 Profile Picture
    4,667 Super User 2024 Season 1 on at

    Hi @dkayt ,
    The formula is working for me.
    Try running OnStart function to test it - 

    NandiniBhagya20_0-1681911683178.png

     

  • dkayt Profile Picture
    517 on at

    HI @NandiniBhagya20 ,

    I did the same too

    dkayt_0-1681911849797.png

    But It doesn't.

  • mmollet Profile Picture
    3,187 on at

    This code works for me. I also tried with Switch(Weekday(Now()), ...rest of your code... ) and that worked as well. Are you getting any errors?

  • dkayt Profile Picture
    517 on at

    Very strange 😞

    I'm getting no error. All variables are "Blank()" even when I'm "Running OnStart"

  • mmollet Profile Picture
    3,187 on at

    I would try to add that code to a button and see if it works when you click it. Thats what I do to debug. Use some text labels to show values as well if you need to.

  • Verified answer
    Bluegres Profile Picture
    9 on at

    Hi,

    the code also works fine for me.

    Do you maybe call the variables somehwere else in your programm?

    If you use them somewhere else in your program, do you always set them properly?

     

     

     

     

  • dkayt Profile Picture
    517 on at

    You are right. I could find it. Now it works finally.

    Thanks @Bluegres 

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 551

#2
WarrenBelz Profile Picture

WarrenBelz 430 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 298

Last 30 days Overall leaderboard