Please follow the steps included below for creating a rollup to find max recently closed activity on the opportunity.
Note: Salesforce does not support any aggregate operations on the 'ActivityDate' field, but we have a workaround here to fulfill the requirement using PWR Rollups please follow the below steps for the solution
To achieve this requirement, the user needs to create a custom formula field.
Create a formula field on the Task/Activity Object with return type Date, Formula = ActivityDate
Open PWR Rollups application
Create a new roll-up and give the appropriate name and description
Select the source object as Task and the destination object as Opportunity, and click next
Select the rollup type as Maximum and for the Source field select the formula field which you have recently created
Select the destination field where you want to show the result (It should be the Date field)
Now, click on the 'Add Condition' button
Please refer to the screenshot below for the filter specifications
Check the checkbox to make rollup active then click on save
Now you have successfully created the rollup to fulfill your requirement.