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
JosephTJosephT 

Time Between Opportunities

I am trying to devise a way to show the average time frame between each opportunity that is created under any given account.  So, if I look at Account A and it has three opportunities associated to it, I would be able to see the average time (days) between the creation of each opportunity.

Any Ideas would be greatly appreciated.
MissedCallMissedCall

You may want to have backend fields on account object along with a field to store the average time to create opportunity. I would have a trigger firing on opportunity insert.

Logic will be something like,

 -- Have (List or whatever) all the opportunities related to an account (keep a count of it)
 -- Take the latest created opportunity's created date and take the oldest created opportunity's date and subtract it
 -- Divide the step 2's number of days with step 1's count of opporutnities for that account
     == number of days between opportunities (populate the field you created on account to store average time between opportunities)

If you want to consider holidays, business hours then the above logic will not work.
JosephTJosephT
Thank you, I appreciate the insight