AI can help you understand an inherited Power Apps formula, but it cannot certify that the formula is correct. Use it to produce a first explanation, identify repeated work and suggest tests. Keep the final judgement with someone who understands the app, its data source and the business rule.
That distinction matters. A plausible explanation is useful. A plausible rewrite that changes who may update a record is dangerous.
The formula we inherited
This example came from a canvas app for a poker game. It tries to move play to the next person after the game starts or a turn exceeds ten seconds.
If(
First(galTablePlayers.AllItems).UniqueID = varCurrentUser.UniqueID,
If(
(
CountRows(galTablePlayers.AllItems) > 1 &&
LookUp(
PokerHands,
Table.UniqueID = varSelectedTable.UniqueID
).PlayerTurn = 0
) ||
(
DateDiff(
LookUp(
PokerHands,
Table.UniqueID = varSelectedTable.UniqueID
).CurrentTurnTime,
Now(),
TimeUnit.Seconds
) > 10 &&
LookUp(
PokerHands,
Table.UniqueID = varSelectedTable.UniqueID
).PlayerTurn > 0
),
Patch(
PokerHands,
LookUp(
PokerHands,
Table.UniqueID = varSelectedTable.UniqueID
),
{
PlayerTurn:
LookUp(
PokerHands,
Table.UniqueID = varSelectedTable.UniqueID
).PlayerTurn + 1,
CurrentTurnTime: Now()
}
)
)
)
In plain English, the formula appears to do three things:
- It checks whether the current user is the first player in the gallery.
- It finds the poker-hand record for the selected table.
- It advances PlayerTurn when the game has more than one player and has not started, or when the recorded turn has lasted more than ten seconds.
The word “appears” is deliberate. The formula alone does not tell us whether gallery order is a valid way to appoint a controller, whether PlayerTurn may exceed the number of players, or whether another device can update the same record at the same moment.
Ask AI for an explanation, not a verdict
A weak prompt asks, “What does this do?”
A better prompt makes uncertainty visible:
Explain this Power Fx formula in plain English.
Separate your answer into:
1. What each condition checks.
2. Which record the formula reads and writes.
3. Assumptions you cannot prove from the formula alone.
4. Possible delegation, permission, blank-value and concurrency risks.
5. A test matrix covering both expected and failure cases.
Do not claim the formula is correct. Do not invent the data-source schema.
Then challenge the response.
- Did it confuse a gallery row with a durable data record?
- Did it notice every LookUp?
- Did it explain what happens when no matching poker hand exists?
- Did it mention two players updating the same record?
- Did it preserve the original conditions exactly?
AI is doing useful translation here. You are still doing the review.
A clearer Power Fx version
The repeated lookup can be named once with With, which keeps the value local to this expression. IfError can also expose a failed write instead of letting the user assume the turn changed.
If(
First(galTablePlayers.AllItems).UniqueID =
varCurrentUser.UniqueID,
With(
{
currentHand:
LookUp(
PokerHands,
Table.UniqueID = varSelectedTable.UniqueID
)
},
If(
IsBlank(currentHand),
Notify(
"The poker hand could not be found.",
NotificationType.Error
),
If(
(
CountRows(galTablePlayers.AllItems) > 1 &&
currentHand.PlayerTurn = 0
) ||
(
DateDiff(
currentHand.CurrentTurnTime,
Now(),
TimeUnit.Seconds
) > 10 &&
currentHand.PlayerTurn > 0
),
IfError(
Patch(
PokerHands,
currentHand,
{
PlayerTurn:
currentHand.PlayerTurn + 1,
CurrentTurnTime: Now()
}
),
Notify(
"The turn could not be updated. Refresh and try again.",
NotificationType.Error
)
)
)
)
)
)
Microsoft documents Patch as a way to modify selected fields in a data-source record. It also recommends handling write failures with IfError or inspecting them with Errors. Failures can come from connectivity, permissions or conflicts with a server-side change. See Microsoft’s Patch reference and Power Apps error-handling guidance.
This rewrite improves readability and error reporting. It does not prove the game logic is safe.
Two clients could read the same PlayerTurn, both pass the condition and then attempt a write. A local With value is a snapshot for this formula evaluation, not a transaction or lock. If exactly-once turn advancement matters, the design needs a server-controlled operation with a tested concurrency strategy.
Check the parts AI cannot see
Data and privacy
Before pasting a formula into any AI service, remove secrets, tenant names, personal data, customer identifiers and proprietary business rules that the service is not approved to process.
Microsoft says prompts, responses and Microsoft Graph data used by Microsoft Copilot are not used to train its foundation models. Microsoft also says Copilot respects the signed-in user’s existing permissions. Those protections apply to the covered Microsoft service and account context, not automatically to every consumer AI tool or browser extension. Read the current Microsoft Copilot privacy and security documentation and your organisation’s approved-tool policy before sharing work material.
Permissions and licensing
Patch succeeds only if the current user and connection may update the target record. The formula itself does not grant access.
Power Apps licensing also depends on the app’s connectors, data sources and environment. A rewrite from AI cannot tell you whether a premium connector or another licence is required. Confirm that in the tenant and against the current Power Apps licensing guidance.
Delegation and loaded data
Patch is a write operation, but the LookUp used to select its base record can still raise a delegation warning depending on the data source and predicate. Microsoft’s delegation overview explains why a nondelegable query can inspect only a limited local portion of a larger source.
The formula also relies on galTablePlayers.AllItems. Gallery state is part of the client interface, so do not assume it represents a complete, authoritative player list without testing that assumption.
A test matrix worth keeping
Run the app with a non-production data set and record the actual result for each case:
| Case | Expected observation |
|---|---|
| No poker-hand record matches the selected table | Error message appears and no write is attempted |
| One player only | PlayerTurn does not advance |
| More than one player and PlayerTurn is zero | The authorised controller can start the turn |
| Active turn is ten seconds or less | No update occurs |
| Active turn exceeds ten seconds | One valid update occurs and the time is recorded |
| Current user is not the first gallery player | No update occurs |
| User lacks update permission | The write fails visibly |
| Two devices cross the threshold together | The observed result is captured and the concurrency design is reviewed |
Use Power Apps Monitor to inspect app events and data calls during testing. Monitor evidence can show what happened in that session. It does not prove every user, data volume or timing combination is safe.
The useful division of labour
AI is good at translating syntax, naming repeated expressions and drafting test cases.
The maker remains responsible for:
- the intended business rule;
- the data model and permissions;
- delegation and scale;
- error and blank handling;
- concurrent writes;
- the evidence that the revised app behaves correctly.
That is a much more useful relationship than either fearing the tool or trusting it.
Explaining a formula is still a chat-shaped job. When you are ready to understand how AI can move from giving advice to completing a bounded task, AI for Work shows you how to brief, supervise, and check an agent without handing over the keys.
If you are untangling an inherited canvas app, bring the redacted formula, data source and failed test to the Power Apps Builders Space.
