This is a two-part rollup. The first part captures the number of activities on an opportunity. The second part makes use of Flow to capture the number of activities completed before a deal was closed. (Note: if an opportunity is re-opened and closed, the number of activities before closed date field will change to match the number of activities field.)
Step 1. Create a field to hold the number activities completed and a field to hold the number of activities completed before deal closed.
Step 2. Create a rollup to the opportunity object; select number of activities field as target field.
Step 3. Select Task as child object and Deleted as source field. Select Count as Rollup Type.
Step 4. Create a record-triggered Flow on the opportunity object.
Step 5. Configure the flow to trigger when a record is created or updated.
Step 6. Change the entry conditions to formula evaluates to true, the formula should be set to
(IsClosed = False) &&
(
ISCHANGED(Number_of_Activities__c) ||
ISCHANGED(IsClosed)
)
Step 7. Optimize the flow for Actions and Related Records.
Step 8. Add an Update Records element below the start and set a label. Under “How to find records to update and set their values”, select “Use the opportunity record that triggered the flow”.
Step 9. Under Set Field Values for the Opportunity Record, select the closed number of activities before the close date field for the field, and select the triggering opportunity and rollup target field for the value.
Step 10. Make sure to activate your flow rule! After this is done your rollup should be up and running!
Updated, 4/7/2026