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
Dragon SlayerDragon Slayer 

Compare forecast from different dates

I want to compare forecast from two different dates e.g. I want to compare today's forecast and tomorrow's forecast and see if the forecast category has changed for any of the records and highlight it. I want to do it on a daily basis so want to automate it. Is it possible and if so then how?
Best Answer chosen by Dragon Slayer
ShashForceShashForce
Hi,

You can do it using a workflow or through an apex trigger.

Workflow:
1.) Create 2 custom fields on opportunity "Forecast Change Date" and "Changed from Forecast category".
2.) Create a workflow rule on opportunity to trigger whenever Forecast Category is changed.
3.) Add 2 field updates on the workflow, one to update "Forecast Change Date" with the current date, and other to update the "Changed from Forecast category" with the old forecast category.
4.) Run a report on opportunities to monitor the changes based on dates.
5.) Please note, this will only track the last change, and not all the changes.

Trigger:
1.) Create a custom object like "Forecast Change".
2.) Write an apex trigger on opportunity to create a "Forecast Change" record with necessary fields, whenever the Forecast Category is changed.
3.) Run a report on Forecast Change records for monitoring.

If this answers your question, please mark this as the Best Answer for this post, so that others can benefit from this post.

Thanks,
Shashank

All Answers

ShashForceShashForce
Hi,

You can do it using a workflow or through an apex trigger.

Workflow:
1.) Create 2 custom fields on opportunity "Forecast Change Date" and "Changed from Forecast category".
2.) Create a workflow rule on opportunity to trigger whenever Forecast Category is changed.
3.) Add 2 field updates on the workflow, one to update "Forecast Change Date" with the current date, and other to update the "Changed from Forecast category" with the old forecast category.
4.) Run a report on opportunities to monitor the changes based on dates.
5.) Please note, this will only track the last change, and not all the changes.

Trigger:
1.) Create a custom object like "Forecast Change".
2.) Write an apex trigger on opportunity to create a "Forecast Change" record with necessary fields, whenever the Forecast Category is changed.
3.) Run a report on Forecast Change records for monitoring.

If this answers your question, please mark this as the Best Answer for this post, so that others can benefit from this post.

Thanks,
Shashank
This was selected as the best answer
ShashForceShashForce
Hi,

Looks like your reply is deleted. Please use the TEXT() function to use the correct picklist values within formulas in Salesforce.

e.g.:

Use TEXT( (ForecastCategoryName) ) instead of JUST ForecastCategoryName
Use TEXT( PRIORVALUE(ForecastCategoryName) ) instead of PRIORVALUE(ForecastCategoryName)

Thanks,
Shashank
Dragon SlayerDragon Slayer
Thanks Shashank!

I figured out that I had to use TEXT() that is why I deleted the question :)
I was able to compare the forecasts using the workflow, didn't try using the Trigger though.
Thanks a lot for your suggestion!
Dragon SlayerDragon Slayer
Hi Shashank,

As a part of the same task, I am trying to convert the Opportunity Amount using the ConvertCurrency function. I used ConvertCUrrency(Amount), but I am getting "Error: Incorrect parameter type for function 'convertCurrency()'. Expected Currency, received Number" even though the type of Amount field is Currency. Any idea why is it so and how can I fix it?

Thanks in advance! 
ShashForceShashForce
Hi,

For ConvertCurrency() to work, the org needs to have multi-currency enabled. Can you check if that is enabled for the org?

Thanks,
Shashank
Dragon SlayerDragon Slayer
Hi Shashank,

Multi-Currency is already enabled for my organization.

Thanks!
ShashForceShashForce
You may have to change the formula return data type to "Currency".
Dragon SlayerDragon Slayer
I even tried that but that doesn't work either. I get the same error.