Power Apps With Function

The Microsoft Power Apps With function is a powerful way to divide complex formulas into smaller pieces. It is useful when used within a ForAll, since we can’t set variables within a ForAll. Since the formula is contained, it is preferred over context variables created using UpdateContext or global variables created using Set.

The syntax looks like this:

With(
 { 
   myValue1: //add some logic
 },
 //Do something with the myValue1result
)

You can also have nested With functions.

With(
 { 
   myValue1: //add some logic
 },
  With(
  {
   myValue2: // do something with myValue1
  },
  //Do something with myValue2
)

Or even run the With function within a ForAll. You can also run ForEach within the With function itself.

ForAll(galMyItems.AllItems As galSelectedItem, 
 With(
 {
   myValue1: //add some logic with galSelectedItem
 },
 //Do something with the myValue1result
 )
)

Date
November 23, 2023
Tags
Architect
Kudos
Buy me a Coffee
Support this site.