function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SCh9SCh9 

Design a solution to get the average time (in hours) taken to close the 5 most recently closed cases on to a custom field at the Account object level

Hello. I am a newbie to Salesforce. 
I am trying to find a solution or how to design a solution to get the average time (in hours) taken to close the 5 most recently closed cases on to a custom field at the Account object level. I will be using this information to see if there is a timely resolution of cases logged on each account. 

My idea of approach to this problem - 
I have created a formula field on Cases object to calculate time taken in hours to close the case. I would use a SOQL query to get the 5 most recent cases (order by ClosedDate DESC LIMIT 5) for each account. Can we achieve a solution to get the average time at the Account level using standard salesforce features (process builders, flows etc.,) without going for custom code ? If it has to be custom code, is Trigger a solution here ?

Can anyone please give any inputs/ suggestions/ ideas ?

Thank you.

NagendraNagendra (Salesforce Developers) 
Hi,

May I suggest you please give a try by exploring Declarative Rollup Summary Tool which might help you with the above requirement. Please let us know if this helps.

Thanks,
Nagendra
SCh9SCh9
Thank you Nagendra. As per our org's limitations, I cannot install the tool.
Can anyone let me know / help to build the solution using apex classes or triggers.
Thank you