Find the sum of formulas for saved search.

To get the sum of all the fields which is created using formula,take the actual formula used to create the fields and adjust the criteria and add them.

For eg: Two fields are created using the formula

coalesce(max(case when {systemnotes.field} in (‘Pipeline stage’) and {systemnotes.oldvalue} in (‘Opportunity’) then {systemnotes.date} when {systemnotes.field} in (‘Deal Status’) and {systemnotes.newvalue} in (‘Won’, ‘Lost’)then {systemnotes.date}end ),  current_date ))-(coalesce(max( case when{systemnotes.field} in (‘Pipeline stage’) AND {systemnotes.newvalue} in (‘Opportunity’) then {systemnotes.date} end),Null)

(coalesce(max(case when {systemnotes.field} in (‘Pipeline stage’) and {systemnotes.oldvalue} in (‘Contact made’) then {systemnotes.date} when {systemnotes.field} in (‘Deal Status’) and {systemnotes.newvalue} in (‘Won’, ‘Lost’)then {systemnotes.date}end ),  current_date ))-(coalesce(max( case when{systemnotes.field} in (‘Pipeline stage’) AND {systemnotes.newvalue} in (‘Contact made’) then {systemnotes.date} end),Null)

To find the sum of these fields we need to change the formula as follows:

NVL((coalesce(max(case when {systemnotes.field} in (‘Pipeline stage’) and {systemnotes.oldvalue} in (‘Opportunity’) then {systemnotes.date} when {systemnotes.field} in (‘Deal Status’) and {systemnotes.newvalue} in (‘Won’, ‘Lost’)then {systemnotes.date}end ),  current_date ))-(coalesce(max( case when{systemnotes.field} in (‘Pipeline stage’) AND {systemnotes.newvalue} in (‘Opportunity’) then {systemnotes.date} end),Null)),0)+NVL((coalesce(max(case when {systemnotes.field} in (‘Pipeline stage’) and {systemnotes.oldvalue} in (‘Contact made’) then {systemnotes.date} when {systemnotes.field} in (‘Deal Status’) and {systemnotes.newvalue} in (‘Won’, ‘Lost’)then {systemnotes.date}end ),  current_date ))-(coalesce(max( case when{systemnotes.field} in (‘Pipeline stage’) AND {systemnotes.newvalue} in (‘Contact made’) then {systemnotes.date} end),Null)),0)

Leave a comment

Your email address will not be published. Required fields are marked *