Pages

Showing posts with label Forecast. Show all posts
Showing posts with label Forecast. Show all posts

Monday, February 21, 2022

Salesforce: Opportunity Split Query

This is the continuation of the previous blog Forecast and Opportunity Split, in this blog, we will share more on Opportunity Split records.

SOQL
SELECT Id, OpportunityId, SplitOwnerId, SplitOwner.Name, CurrencyIsoCode, SplitAmount, Opportunity.CloseDate FROM OpportunitySplit WHERE SplitAmount <> 0 AND Opportunity.ForecastCategory = 'Closed' AND SplitTypeId = '1492v0000008opLAAQ' AND Opportunity.CloseDate > 2019-06-30 AND Opportunity.CloseDate < 2019-10-01 ORDER BY Opportunity.CloseDate DESC 


Summary:
  • The number of rows here is based on the number of split records that fit the criteria, so there is no summarized calculation as in ForecastingItem
  • The currency can be different based on the currency defined for the opportunity
  • The Split Amount is not roll-up to the manager.

Sunday, September 1, 2019

Salesforce: Forecast with Opportunity Split

This is the continuation of previous blog Setup Forecast Quota, in this blog, we will share about Forecast with Opportunity Split Overlay.

1. Opportunity Team and Opportunity Splits


Here is the scenario:
Two users, both users have been enabled for Forecast
1. Johan Forecast is the manager
2. George Mann report to Johan Forecast

Two closed-won opportunities with Overlay split:

opportunity #1

opportunity #2


2. Forecast
Let us the result see in the Forecast tab:


Highlight legend:
- Yellow: this is quota as we discussed in the previous blog
- Pink: this is the forecast item for Closed forecast
- Green: this is summary from all subordinates, including the manager
- Blue: USD 305,500.00 comes from opportunity #2 which is the total amount for the 2nd and 3rd; USD 75,000.00 is from opportunity #1


3. SOQL
SELECT Id, OwnerId, ForecastAmount, Owner.Name, PeriodId, ForecastingTypeId FROM ForecastingItem WHERE ForecastCategoryName = 'Closed' AND ForecastingTypeId = '0Db2v000005aTHcCAM'


Summary:
  • The Forecast Amount in ForecastingItem is auto-populated from Opportunity Split Amount based on the Forecast Type and Forecast Category.
  • The Period Id in ForecastingItem is auto-populated based on Opportunity Closed Date.
  • Each user will only have 1 line for ForecastingItem in a period for a Forecast Type.
  • If you have multi-currencies enabled, only 1 currency will be returned in the query result, this currency is based on defined Corporate Currency.
  • The Forecast Amount from ForecastingItem in SOQL is roll-up to the manager, and managers numbers will roll-up to the managers' manager.

Forecast Manager in Forecast Hierarchy

Sample:
There are 2 users under Staff 1: Song Lee & Free Man

Forecast tab

SOQL
SELECT Id, OwnerId, ForecastAmount, Owner.Name, PeriodId, ForecastingTypeId FROM ForecastingItem WHERE ForecastCategoryName = 'Closed' AND ForecastingTypeId = '0Db0k000000076kCAA' ORDER BY ForecastAmount



What will happen if we remove Maria Ann as Forecast Manager for the role hierarchy General Manager?

Forecast tab

Notice:
1. The Amount is no longer rollup from Maria Ann subordinates'. Forecast managers see forecast rollups from users below them in the forecast hierarchy.
2. Click the arrow next to label 'Maria Ann' will not drill down to the subordinates level.
3. Jack Bob numbers are only from Linda Yie as Maria Ann not contributing anything.
4. The number from Song Lee and Free Man are not roll-up to anyone.

SOQL
SELECT Id, OwnerId, ForecastAmount, Owner.Name, PeriodId, ForecastingTypeId FROM ForecastingItem WHERE ForecastCategoryName = 'Closed' AND ForecastingTypeId = '0Db0k000000076kCAA' ORDER BY ForecastAmount



If Maria Ann have her owned Opportunity Splits


Same for SOQL result, Maria Ann will have USD 18,000.00 for the Forecast Amount.


Now, let us remove Allow Forecasting from Maria Ann

Maria Ann does not appear in the Forecast tab at all.



SOQL:


Remember that Maria Ann still owned Opportunity Split, but she does not appear in both Forecast and SOQL.


Summary:
1. Allow Forecasting is a must for all forecast users.
2. Each manager role in the forecast hierarchy should have a user assigned as the Forecast Manager.
3. The API name for "Allow Forecasting" is ForecastEnabled, you can mass update it with API.



Salesforce: Setup Forecast Quota


1. Enable Opportunity Team
  



2. Enable Opportunity Split and Add Opportunity Split Type (optional)
For this blog, I am adding Overlay opportunity split type



 3. Enable Forecast, Add Forecast Type (optional), and Enable Quota

enable forecast

adding forecast type 

You may need to refresh your web browser to see the “Forecasts Quotas” tab to appear.


4. Enable user for “Allow Forecasting”
From the user detail page or Forecast Hierarchy.

user detail


forecast hierarchy

  
 5. Assign Quotas to Users
Make sure you select the right Forecast Type and select the right currency (if necessary)
Or use the Data Loader tool to load CSV into Forecasting Quota object



6. Set Forecast Manager for each Role Hierarchy
This is only necessary if user have subordinates as per role hierarchy, set up this from Forecast hierarchy.


7. Verify Quota

7A. Forecast Tab
Make sure to select correct Period, Forecast Type, and Currency



7B. SOQL
As mentioned in (5), we can use Data loader to load quota to Forecast Quota object. So, the same we can query from Forecast Quota object too.

SELECT Id, QuotaOwnerId, QuotaAmount, QuotaOwner.Name, ForecastingTypeId, PeriodId FROM ForecastingQuota



  • From the above query, this shows us that Quota Amount numbers are NOT roll-up from subordinates to the manager.
  • The currency here is based on currency defined when added the quota for each users.


Reference:

Monday, July 1, 2019

Salesforce: ForecastingQuota and ForecastingItem object

ForecastingQuota, this object stores an individual user’s or territory’s quota for a specified time period. The “Manage Quotas” user permission is required for creating, updating, or deleting quotas.  The “View All Forecasts” permission is required to view any user's forecast, regardless of the forecast hierarchy. Available in API versions 25 and greater. Object Id prefix is 0J9.

Once the quota added from the setup menu or Data Loader, it will be stored in this object and you can query it.



Query ForecastingQuota
SELECT Id, ForecastingTypeId, QuotaAmount, QuotaOwnerId, QuotaOwner.Name, StartDate FROM ForecastingQuota ORDER BY StartDate DESC



ForecastingItem, this is a read-only object used for individual forecast amounts. Users see amounts based on their perspectives and forecast roles. Available in API versions 26 and greater. Object Id prefix is 0G3.

The amounts users see include one of the following when forecasting in revenue: AmountWithoutAdjustments, AmountWithoutManagerAdjustment, ForecastAmount, OwnerOnlyAmount.

The amounts users see include one of the following when forecasting in quantity: QuantityWithoutAdjustments, QuantityWithoutManagerAdjustment, ForecastQuantity, OwnerOnlyQuantity.

Additionally, note that users:
- with the “View All Forecasts” permission have access to all ForecastingItem fields.
- without the “View All Forecasts” permission have access to all fields for their own subordinates and child territories.
Other users can see the ForecastingItem object, but not its records.

Let us see a sample of how the data is stored
SELECT Id, OwnerId, Owner.Name, ForecastAmount, ForecastCategoryName, ForecastingTypeId, PeriodId FROM ForecastingItem WHERE Period.StartDate = 2019-07-01 ORDER BY ForecastingTypeId, Owner.Name, ForecastCategoryName

** unfortunately we cannot do relationship query for ForecastingType from this object

figure 1

Notes from the above query and the result:
- ForecastCategoryName is Forecast Category which is mapped to Stage
- There is no forecast period in this object, but PeriodId, so we can use it to determine Forecast period
- ForecastingTypeId is referred to Forecast Type configured

Query ForecastingType
SELECT Id, DateType, DeveloperName, MasterLabel, RoleType FROM ForecastingType WHERE IsActive = true

soql result from ForecastingType


Now let us see the data by running an Opportunity report:

figure 2


Then let us also see the Forecast result:

figure 3

Now, let us compare how is the data stored in ForecastingItem object, remember this object is read-only, so we can't update it manually.

  • Figure 1; row 1; Charlie User C in Jul 2019; for Forecast Category = Pipeline with Forecast Amount = $55,000 -- if you see figure 3, it is $0 for Charlie User C, but since Dave User D is reported to Charlie in the role hierarchy, so amount from Dave roll-up to Charlie. 
  • Figure 1; row 2; Charlie User C in Jul 2019; for Forecast Category = Closed with Forecast Amount = $295,000 -- look at figure 3, this amount is sum of $120,000 (Dave's amount) + $139,500 (Charlie's amount). If we further drill Charlie's amount of $139,500 -- look at figure 2, it is the sum of row 1 ($50,000) and row 2 ($89,500)
  • Figure 1; row 3; Dave User D in Jul 2019; for Forecast Category = Pipeline with Forecast Amount =$55,000 -- as no one report to Dave in the role hierarchy, this number is only his opportunity, drill down to figure 2, it is row 3 ($15,000) + row 4 ($40,000) 
  • Figure 1; row 3; this is simply Dave User D amount for Forecast Category = Closed
  • Figure 2; row 6; this is not calculated into ForecastingItem, because forecasting setting in this example in monthly, while row 6 closed date is Aug 2019.

Make sure Charlie User C is enabled as Forecast Manager in Forecast Hierarchy, otherwise Dave number (and all other users under Charlie) will not roll-up to Charlie.


In this sample, we are using monthly forecast setting, Salesforce also supports option to use Quarter forecast period too.



Reference:


Sunday, June 30, 2019

Salesforce: Forecast attainment report

Forecast is always a big part in CRM, and of course, it is available in Salesforce. Forecast has been gone through 3 types in Salesforce, with the current Forecast called "Collaborative Forecast", even you will see it just as "Forecast" in the setup menu, tab, and label.

We have discussed collaborative forecast many times in this blog, and today will discuss Forecast attainment report. But, here are blogs related to collaborative forecast:

Some of the above blogs probably not updated, particularly since the Lightning experience, e.g. to set user quota, there is a setup menu in Lightning called "Forecasts Quotas", this menu is not visible in Classic setup menu, but of course, you can still use Data Loader to load user quotas.


Here is the step to create a quota attainment report:

Create Custom Report Type
1. For Primary Object, select Forecasting Quotas
2. For Report Type Label, enter Forecasting Details
3. Add description, such as "Forecast Items and Quota"
4. Store in Forecast category
5. Select Deployed and Next
6. Click to relate another object, select object Forecasting Items
7. Select "A records may or may not have related B records"
8. Click Save



Add Quota from the Setup menu
1. Make sure you are in Lightning and "Show quotas" has been enabled in Forecasts Settings.
2. Navigate to the setup menu and search for Forecasts Quotas.


3. Select a forecast period and forecast type, then click "Show Quotas".
4. Search by username or roles; then enter the Quota and Currency for each user within the selected period.


Forecast
Let us see a sample of Forecast with some adjustment made by the manager and the user.


As you see there are a few manual adjustments marked with orange triangles.


Quota Attainment Report
Now, let us create a quota attainment report using report type created above in this blog.


Notes:
- Maria Jones quota for Q2-2019 is USD 80,000.00 -- this is "Quota Amount"
- Maria Jones closed won opportunity for Q2-2019 is USD 30,000 -- this is "Forecast Amount"
- There is an adjustment of USD 5,000.00 made by Maria Jones's manager for Q2-2019 for Booked category

- Mars Rover quota for Q2-2019 is USD 100,000.00 (Quota Amount)
- He has closed won opportunity USD 150,000.00 (Forecast Amount) which is 50% over his target
- There is an adjustment of USD 7,000.00 made by Mars Rover himself for Q2-2019 for Booked category



Reference: Trailhead module Create Forecasting Reports



Sunday, February 24, 2019

Salesforce: Using Custom Field for Forecasts

This blog only applicable for Collaborative Forecast, as per latest announcement, Customizable Forecast is scheduled for retirement as of Summer ’20.

By default, Salesforce will forecast using Amount field from Opportunity for Revenue forecast. However, to fit your business needs, you can add additional forecast type using custom fields in Opportunity, and the fields must be a currency field.

1. Opportunity Split
In this blog, I will add a custom currency field from Opportunity called Extra Income. I'll select the field 'Extra Income' and type in 'Extra' as Split Label.


Tips: on the Split Type, the Totals 100% must be ticked, otherwise, forecast with the custom fields will not work.


2. Forecast Setting
Now, I need to configure forecast setting, click the link "+ Add another forecast type" then select Extra.


Then, you select a Forecast Measurement (Revenue or Quantity) and select fields to show in the Opportunity List.
You need to click Save button to save, otherwise, it will not save, even you have click OK button in many screens.


Forecasts tab
Now, let us see if this will work.

This is the default forecast based on Amount, it called Opportunity Revenue.



Now, let us flip to the new Extra forecast we just create, click the gear icon on the top right.



Now, let us forecast with our new forecast type "Extra"




ReferenceEnable Custom Field Forecasts in Collaborative Forecasts



Friday, February 23, 2018

Salesforce: Setup Overlay Splits Forecast

This blog is only applicable for Collaborative Forecast, not the old Customizable Forecast.

For revenue split forecast, check out this Setup Forecast with Revenue Split. This blog will share on using Overlay Splits Forecast. To enable Overlay Splits Forecasts, here a few things need to perform:

1. Enable Opportunity Team Selling
Search Opportunity Team Settings and enable Team Selling. You can add the Opportunity Team related list to the page layout.



2. Enable Opportunity Splits
- Search for Opportunity Splits, then click Setting.
- Click "Set up Opportunity Splits" button
- By default "Revenue" and "Overlay" are active, no need to change anything here.
- Click Save button and Enable to confirm.
- You will get an email once Opportunity Splits are enabled.
- Add "Opportunity Splits" related list to the page layout.


3. Enable Forecast
- Search Forecasts Settings
- Select "Enable Forecast"
- Click link "+ Add another forecast type"
- Select "Opportunity Overlay Splits"
- Click OK button and Save button



4. Forecast Tab
Now in the forecast tab, click the gear icon, you should see an option for "Overlay Splits"



Once you have opportunity split by Overlay, you will see the number shown in Forecast when select Overlay Splits.

In Opportunity Related List


In Forecast Tab


ReferenceOverlay Splits Forecasts in Collaborative Forecasts



Friday, April 24, 2015

Salesforce: Change Forecast Type and the Effects

This blog is based on Collaborative Forecast in Salesforce.

There are 5 Forecast Category in Opportunity, where you cannot add or remove the category, but you can re-label the values. Out of the box, here is the Forecast Type and Status Category:
Forecast Type Status Category
  • Omitted -> Omitted
  • Pipeline -> Pipeline
  • Best Case -> Best Case
  • Commit -> Commit
  • Closed -> Closed

You can change Forecast Type label to:
  • Omitted -> Omitted
  • Pipeline -> Pipeline
  • ABC -> Best Case
  • XYZ -> Commit
  • Won -> Closed

Notice that Status Category cannot be modified, even you change the Forecast Type from Best Case to ABC, the category still ‘Best Case’ at the back end, same for XYZ.

There are 3 values for Opportunity Stage Type, it is also not modify-able or add new values:
  • Open             -> available status category: Omitted, Pipeline, Best Case, Commit
  • Closed/Won    -> available status category: Omitted, Closed
  • Closed/Lost     -> available status category: Omitted
Above mapping is not customize-able, vote here!

Relation with Forecast, forecast will always show 4 forecast type (as above values, except Omitted)



Relation with report, report with report type = Opportunity will have additional filters:
  • Opportunity Status = Any, Open, Closed, Closed Won (this is not modified able vote here)
  • Probability

If we have correct mapping of Stage Name versus Type, it will not cause any issues for Opportunity Status report option.

When adding ‘Forecast Category’ as report filter, we will have option: Omitted, Pipeline, ABC, XYZ, Won – so if we use Pipeline, this should be filter only to Open opportunities if we have correct mapping of Stage Name versus Forecast Category.



Sunday, December 21, 2014

Adding Quota in Salesforce.com Collaborative Forecast

This would be another blog on Collaborative Forecast, see adding Opportunity Split and Configuring Collaborative Forecast blog earlier.

What is Quota?
  • Revenue target or sales goal within a time frame
  • To keep track of performance against plan
  • Keeps revenue goals in sight
  • Can be expressed as dollar amounts, units or product or both.
Back to Universal Container scenario, each sales rep should have quota they have to achieve as part of their performance. Here is the role hierarchy:


Each user have their own quota, include Sales Manager and Country Manager.
Each user also owned opportunity, the opportunity number of Sales Rep will roll-up to their Sales Manager, and Sales Manager number will roll-up to the Country Manager. So, all number will roll-up to the user in top hierarchy.

1. Enable Quota
Navigate to Setup | Customize | Forecasts | Settings, enable Show Quotas and click Save button.



2. Set User Quota
Until Winter '15 release, there are no manual to load or set quota to user manually from Salesforce website, You have two option:
  1. Use Data Loader to load quota to all users, see the details and step-by-step here Load Quota Data for Forecasts
  2. Install an app from AppExchange called Edit Quotas, this is a free app developed by Salesforce Labs, although it is an app salesforce from salesforce labs, but it still consider as external app, meaning no support from Salesforce support.
You need to select a Forecast Type for each quota (if you have more than 1 forecast type). 
The data loaded in Salesforce to Forecasting Quota object, you can use any API to check and confirm it loaded successfully.

3. Forecasts with Quota
Now, it's time to confirm if it works. Click Forecasts tab, you should see a new column Quota at the left before all 4 columns for Forecast Category value.


When you click the period, as user in top role hierarchy, you will see all opportunity number will roll-up to the Forecast Category included opportunity owned by the user itself, it showed as "My Opportunities" after all direct user in the Period. 

Each user will have their own quota and it is not related to the quota owned by other user in the role hierarchy.

Notice at the top right area, you will see new link Display Options, you can enable to show Quota % Attainment.

Once you select Show Quota % Attainment, it will show percentage of amount for each user compare to the quota for each Forecast Category.



When you drill down to your sub-ordinate, it will show the same thing for people under that sub-ordinate.


Reference

Page-level ad