A Copilot Studio developer needs to build an agent topic that retrieves a list of pending approval requests from a Dataverse table, adds a computed field called 'DaysOverdue' to each record based on the difference between today's date and the RequestDate column, and stores the enriched records back into a variable. The DaysOverdue field does not exist in the Dataverse table. Which Power Fx approach correctly adds a computed column to the existing records and stores the result?
Select an answer to reveal the explanation.
Short Explanation and Infographic
AddColumns is like a spreadsheet's 'insert computed column' feature — it takes your existing table and appends a new virtual column calculated on the fly, without touching the original data source. Wrap it in ClearCollect to store the result, and stack Filter inside it to narrow the records before the calculation runs. That AddColumns-inside-ClearCollect-with-Filter combo is the canonical Power Fx pattern for enriching a filtered dataset.
Full explanation below image
Full Explanation
Power Fx's AddColumns function creates a virtual augmented table by appending one or more calculated columns to an existing table expression. It does not modify the underlying data source — it produces a new in-memory table with the additional columns. This is the correct tool for adding computed fields that do not exist in Dataverse.
Option A is correct because the expression composes three Power Fx functions correctly: Filter(ApprovalRequests, Status = "Pending") narrows the Dataverse table to pending records; AddColumns(..., "DaysOverdue", DateDiff(RequestDate, Today(), Days)) appends the computed DaysOverdue column to each filtered record, calculating the number of days between the request date and today; and ClearCollect(varEnrichedRequests, ...) stores the enriched table in the topic variable. This is the standard pattern for creating an in-memory enriched dataset.
Option B is incorrect because ForAll with Collect only collects the DaysOverdue value into the variable — it does not preserve the other columns from the original ApprovalRequests record. The resulting variable would contain only {DaysOverdue: number} records without any of the other approval request fields. ForAll is also less efficient than AddColumns for bulk operations because it iterates record by record.
Option C is incorrect because Patch is used to update existing records in a data source — it cannot add a new column to an in-memory collection variable. After ClearCollect populates varEnrichedRequests, calling Patch on it with a DaysOverdue field would attempt to write DaysOverdue to the Dataverse table (which doesn't have that column), causing a runtime error. Patch is a write operation, not a column addition operation.
Option D is incorrect because UpdateContext is designed to set individual context variables, not table-type variables containing multiple records in a Copilot Studio topic. Additionally, using UpdateContext with AddColumns(ApprovalRequests, ...) without a Filter clause would attempt to load and enrich the entire ApprovalRequests table — potentially thousands of records — into memory, creating a performance problem. ClearCollect is the correct function for storing table-type data in agent topic variables.
Exam tip: Power Fx column manipulation functions: AddColumns() adds computed columns to a table expression, DropColumns() removes columns, RenameColumns() renames columns, ShowColumns() returns only specified columns. All four produce a new virtual table without modifying the source. Combine with Filter() before the column operation to reduce the working dataset, and wrap in ClearCollect() to persist the result.