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
Somasundaram SubramanianSomasundaram Subramanian 

formula field for certain condtions

I have a formula field and I have a picklist field called stagename, it has  5 single vaues 
the formula field should get value of  Account.Account_FY_Franchis__c (field from account)
only when the stagename is "1" or "2"  for other stagenames this formula field should not change , is it possible?
thanks
SwethaSwetha (Salesforce Developers) 
HI Somasundaram,

It should be possible to create a formula field that gets the value of Account.Account_FY_Franchis__c only when the StageName is "1" or "2." For all other StageName values, the formula field will not change its value.

Try
IF(
    ISPICKVAL(StageName, "1") || ISPICKVAL(StageName, "2"),
    Account.Account_FY_Franchis__c,
    Old_Formula_Field__c  // Replace "Old_Formula_Field__c" with the API name of the existing formula field (if any)
)

If this information helps, please mark the answer as best. Thank you
Somasundaram SubramanianSomasundaram Subramanian
that is the challenge by using formula field how to get value only for stage 1 or stage2 and for other stage it should not update
Somasundaram SubramanianSomasundaram Subramanian
if i use below in old field value If(stagename=1 or stagename=2 , account.franchise, here for else we have to give some value what can we give
Andrey BoarskijAndrey Boarskij
If you are tired of the daily routine and constant work that is repeated day after day and nothing new happens - then let me tell you about the modern and unique Indian online casino and bookmaker - Crickexs https://crickexs.in/ . Here you will have the opportunity to bet on the most popular sports matches, as well as more than a thousand different online casino games, where you can hit the jackpot and get a huge amount of money!
victor marcel 8victor marcel 8
Yes, it is possible to achieve this using a formula field. You can create a formula field that checks the value of the picklist field (stagename) and conditionally assigns the value of Account.Account_FY_Franchis__c only when the stagename is "1" or "2". For other stagenames, the formula field can remain unchanged.
Arun Kumar 1141Arun Kumar 1141
Hi Somasundaram,

Try the below formula to achieve this functionality,
 
IF(ISPICKVAL(StageName, "1") || ISPICKVAL(StageName, "2"), Account.Account_FY_Franchis__c, [existing_field])

Hope this helps.

Thanks.
gass sawwgass saww
Hi @Somasundaram
To create a formula field based on specific conditions, you can use Salesforce's formula field capabilities. Here's a general outline of the process:
Navigate to Object Manager: Go to Salesforce Setup, and in the Quick Find (https://spotiapks.com/spotify-vs-pandora-which-music-streaming-is-best/) box, type "Object Manager." Then, select the object (e.g., Opportunity, Account) where you want to create the formula field.
Create a New Formula Field: Inside the Object Manager for your selected object, find and select "Fields & Relationships." Click "New" to create a new field, and choose "Formula" as the field type.
Define the Formula: In the formula editor, you can use functions and operators to set up your desired conditions. For example, you can use IF statements to check certain conditions and return specific values based on those conditions. Here's a simplified example:
IF(Condition1, ValueIfTrue1, 
   IF(Condition2, ValueIfTrue2, 
      DefaultValue))

Replace "Condition1" and "Condition2" with your specific conditions, "ValueIfTrue1" and "ValueIfTrue2" with the values to be returned if those conditions are met, and "DefaultValue" with a fallback value if none of the conditions are true.
Test Your Formula: Salesforce provides a "Check Syntax" button to validate your formula for errors. Make sure your formula is error-free.
Save the Formula Field: Once your formula is correct and error-free, save the formula field.
Add the Field to Page Layouts: To make the field visible and accessible on records, you'll need to add it to the appropriate page layouts. Go to the Page Layout section in Object Manager, find the desired layout, and drag the new formula field onto the layout.
Security and Permissions: Ensure that the appropriate profiles and permissions have access to this new formula field.
Test Your Formula in Real Records: Finally, test your formula field on actual records to ensure it behaves as expected under various conditions.
Remember that the specific functions and syntax used in your formula will depend on your conditions and what you want the formula to calculate or display. Salesforce's formula field capabilities are quite powerful and can handle a wide range of scenarios.