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 / Set multiple variables...
Power Apps
Answered

Set multiple variables with Set function?

(0) ShareShare
ReportReport
Posted on by 33

So, I'm pretty sure I know the answer to this but I'm hoping someone can guide me in another way to do what I'm doing.  I have the below If statement (I actually have four of them that are similar but just set the variables to different values based on the condition):

 

If(
 And(
 varProductType = "Advanced",
 varCareType = "Plus"
 ),
 UpdateContext(
 {
 varDescription_3: Filter(
 Products,
 ProductDescription = ddoCare.SelectedText.Value & " for " & cboDescription_1.Selected.ProductDescription
 ),
 varDescription_4: Filter(
 Products,
 ProductDescription = ddoCare.SelectedText.Value & " for " & cboDescription_2.Selected.ProductDescription
 ),
 varDescription_5: Filter(
 Products,
 ProductDescription = ""
 ),
 varDescription_6: Filter(
 Products,
 ProductDescription = ""
 ),
 varDescription_7: Filter(
 Products,
 ProductDescription = ""
 )
 }
 )
)

 

I have come to the point where I need to make the variables Global.  However, from everything I have read, I can use the Set function to set multiple variables at once like you can with UpdateContext.  I really don't want to have to create an If statement for every single variable because I have three more If statements like the one above so I would end up with 20 If statements.  I could do but it just seems like there would be a better way.

 

Any thoughts?

Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    155,479 Most Valuable Professional on at

    Hi @Tarterman ,

    Actually not much more code for global

    If(
     varProductType = "Advanced" && varCareType = "Plus",
     Set(
     varDescription_3,
     Filter(
     Products,
     ProductDescription = ddoCare.SelectedText.Value & 
     " for " & cboDescription_1.Selected.ProductDescription
     )
     );
     Set(
     varDescription_4,
     Filter(
     Products,
     ProductDescription = ddoCare.SelectedText.Value & 
     " for " & cboDescription_2.Selected.ProductDescription
     )
     );
     Set(
     varDescription_5,
     Filter(
     Products,
     ProductDescription = ""
     ),
     );
     Set(
     varDescription_6,
     Filter(
     Products,
     ProductDescription = ""
     );
     Set(
     varDescription_7,
     Filter(
     Products,
     ProductDescription = ""
     )
     )
    )

     

    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.

  • Tarterman Profile Picture
    33 on at

    Thanks @WarrenBelz.  That was way easier than I thought.  For some reason, I thought that a semicolon marked the end of a statement (which it does) but I didn't realize you could do that in the middle of another statement.  Thanks again for the help.

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 432

#2
Valantis Profile Picture

Valantis 362

#3
timl Profile Picture

timl 337 Super User 2026 Season 1

Last 30 days Overall leaderboard