@Anonymous
With is one of the more powerful functions in PowerApps that you will use. Once you start using it, you will find it invaluable. Beyond the ability to simplify your formulas, it also reduces variables that are in your app. In general, variables should be avoided as much as possible, but there are many times that you need (or want) to encapsulate something in a variable only for the purpose of a formula you are writing. Using the With function allows you to have this type of variable while not incurring the cost of having the variable in your overall app (eases maintenance of your app as well).
As a basic example, consider the following formula:
{
Record: 1,
Title: LookUp(someDataSource, someColumn = "SomeValue" && someOtherColum = "SomeOtherValue" && DateColumn >= DateAdd(Today(), -10, Days) && DateColumn <= Today(), Title),
ColA: LookUp(someDataSource, someColumn = "SomeValue" && someOtherColum = "SomeOtherValue" && DateColumn >= DateAdd(Today(), -10, Days) && DateColumn <= Today(), ColA),
ColB: LookUp(someDataSource, someColumn = "SomeValue" && someOtherColum = "SomeOtherValue" && DateColumn >= DateAdd(Today(), -10, Days) && DateColumn <= Today(), ColB),
ColC: LookUp(someDataSource, someColumn = "SomeValue" && someOtherColum = "SomeOtherValue" && DateColumn >= DateAdd(Today(), -10, Days) && DateColumn <= Today(), ColC),
ColD: LookUp(someDataSource, someColumn = "SomeValue" && someOtherColum = "SomeOtherValue" && DateColumn >= DateAdd(Today(), -10, Days) && DateColumn <= Today(), ColD)
}
Using the With function, it becomes this:
With(LookUp(someDataSource, someColumn = "SomeValue" && someOtherColum = "SomeOtherValue" && DateColumn >= DateAdd(Today(), -10, Days) && DateColumn <= Today()),
{
Record: 1,
Title: Title,
ColA: ColA,
ColB: ColB,
ColC: ColC,
ColD: ColD
}
)
Not only is the above cleaner to read, it also is more performant as we only do 1 lookup as opposed to 5.
I could site a million examples of how great with is...the above is just one.
I hope this is helpful for you.