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.

ForAll(galMyItems.AllItems As galSelectedItem, 
    With(
    {
        myValue1: //add some logic with galSelectedItem
    },
        With(
        {
            myValue2: //add some logic using myValue 1
        },
            //Do something with the myValue1 or 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
    )
)

You'll only receive email when they publish something new.

More from The Power Architect
All posts