Skip to main content

#Formulas38 diskutieren mit

I did some searching before I decided to ask this question, as most of calculating business dates refer to a date/time field, and I only need it for just regular date fields.  The business case is that I track internal SF and general Tech requests and I have a Start Date and an End Date.  I don' go by the created date, as often I have to open up tickets and back date what the start date should have been, or adjust the actual start date from the created date.

 

I have a field called # of Days Open and at this time, this is the formula. 

IF( ISBLANK(  Close_Date__c  ) , TODAY() -   Start_Date__c   ,  Close_Date__c   -  Start_Date__c  )

 

I want to modify it, to account for business days (ie, not counting Sat and Sun, in the calculation).  At this time I don't care about Holidays, as I am not sure how to even do that, as we don't get all of the Standard Holidays off.  

 

I was able to create this formula (based off a blog post) but it doesn't take into account if the request is still open like my IF statement.

 

ABS(

 

CASE(MOD (Start_Date__c- DATE(1985,6,24),7),

0 , CASE( MOD(Close_Date__c  - Start_Date__c

,7),1,2,2,3,3,4,4,5,5,5,6,5,1)

,

1 , CASE( MOD(Close_Date__c - Start_Date__c

,7),1,2,2,3,3,4,4,4,5,4,6,5,1),

2 , CASE( MOD(Close_Date__c  - Start_Date__c

,7),1,2,2,3,3,3,4,3,5,4,6,5,1),

3 , CASE( MOD( Close_Date__c  - Start_Date__c

,7),1,2,2,2,3,2,4,3,5,4,6,5,1),

4 , CASE( MOD( Close_Date__c  - Start_Date__c

,7),1,1,2,1,3,2,4,3,5,4,6,5,1),

5 , CASE( MOD( Close_Date__c  - Start_Date__c

,7),1,0,2,1,3,2,4,3,5,4,6,5,0),

6 , CASE( MOD( Close_Date__c  - Start_Date__c

,7),1,1,2,2,3,3,4,4,5,5,6,5,0),

999)

+

(FLOOR((( Close_Date__c ) - ( Start_Date__c) )/7)*5)-1 +

 

( Close_Date__c - Start_Date__c) -  (Close_Date__c  -

Start_Date__c))

 

I also don't pretend to completely understand how this formula is working (just a plain ole Admin here) but I am thinking there has to be a way to do it without basically repeating this(?)

 

Thoughts?

4 Antworten
  1. Eric Burté (DEVOTEAM) Forum Ambassador
    1. Juli 2024, 21:30

    Hello @Heath Parks please have a look at this online help article on the same subject :

    https://help.salesforce.com/s/articleView?id=sf.formula_examples_dates.htm&type=5

     

    Find the Number of Weekdays Between Two Dates

    Calculating how many weekdays passed between two dates is slightly more complex than calculating total elapsed days. In this example, weekdays are Monday through Friday. The basic strategy is to choose a reference Monday from the past and find out how many full weeks and any additional portion of a week have passed between the reference date and your date. These values are multiplied by five for a five-day work week, and then the difference between them is taken to calculate weekdays.

    (5 * ( FLOOR( ( date_1 - DATE( 1900, 1, 8) ) / 7 ) ) + MIN( 5, MOD( date_1 - DATE( 1900, 1, 8), 7 ) ) )

    -

    (5 * ( FLOOR( ( date_2 - DATE( 1900, 1, 8) ) / 7 ) ) + MIN( 5, MOD( date_2 - DATE( 1900, 1, 8), 7 ) ) )

    PS : it will not handle if the case is in stand by within the overall period. It will just consider the difference between both dates

    PPS : Could you please explain the IF rule you have mentioned on your post. How do you expect the calculation to be impacted ?

    Eric

0/9000

QQ on a formula explanation please:    ABS({!$Record.Amount__c}*{!$Record.Currency__r.USD_FX_Rate__c} / {!$Record.Account_Name__r.USD_Valuation_Total__c}) * 100    Could you please assist?   

2 Antworten
  1. 26. Mai, 12:46

    Hi @Alex Nis, This formula is calculating the percentage contribution of an objects amount against the Account’s total USD valuation.ABS({!$Record.Amount__c}*{!$Record.Currency__r.USD_FX_Rate__c} / {!$Record.Account_Name__r.USD_Valuation_Total__c}) * 100 

     

    Please see the explanation for the each part in the formula,

    • Amount__c → The current record amount. 
    • Currency__r.USD_FX_Rate__c → Exchange rate used to convert the amount into USD. 
    • Amount__c * USD_FX_Rate__c → Converts the amount into USD value. 
    • USD_Valuation_Total__c → Total USD valuation from the related Account. 
    • / USD_Valuation_Total__c → Finds what portion of the total this record represents. 
    • ABS(...) → Ensures the result is always positive, even if the amount is negative. 
    • * 100 → Converts the decimal into a percentage. 

    Example If Amount is 500 ,  FX Rate is 1.2  and Account Total USD Valuation is 6000 means, It would be,

    (500 * 1.2) / 6000 * 100= 600 / 6000 * 100= 10%

    So the formula returns 10%

     

    Hope this works for you!

0/9000
What is a benefit of developing applications in a multi-tenant environment?

A. Access to predefined computing resources

B. Default out-of-the-box configuration

C. Enforced best practices for development

D. Unlimited processing power and memory
2 Antworten
  1. 20. Mai, 05:56

    What is a benefit of developing applications in a multi-tenant environment?

    A. Enforced unit testing and code coverage best practices

    B. Access to predefined computing resources

    C. Unlimited processing power and memory

    D. Preconfigured storage for big data 

    Which one is the correct option?

0/9000
Conversion of OST files into Outlook PST is really a tough task and it becomes necessary if your files have been corrupted. In this situation, you will need a converter like ATS OST to PST Converter which has tremendous advantages that help to make the conversion process simple and modest. The user can directly migrate all their database into Office 365 & Live Exchange Server.

Visit here:  https://microsoft-office.wonderhowto.com/forum/best-way-convert-ost-file-pst-file-via-using-ats-ost-pst-converter-tool-0184450/
14 Antworten
  1. 19. Mai, 13:01

    If you are facing any kind of difficulty with recovering OST files to PST format, then I would like to suggest you to take help of Recoveryfix OST to PST Converter tool. It recovers corrupt OST files & converts them into multiple formats like  PST, DBX, MBOX, MSG, EML, TXT, RTF, HTML, MHTML, PDF, DOC, and DOCX. This OST to PST Converter tool supports all MS Outlook versions like Office 365, 2021, 2019, 2016, 2013 (both 32 bit and 64 bit), 2010, 2007, 2003, 2002, 2000, 98, 97 

0/9000

Hello, I am struggling to get a text formula field to display the corect information.  I have the following formula:     IF( AND(RecordType.Name = 'Asset', CONTAINS( ProductHierarchy__r.NRElement__r.Name, 'Water')),'Yes', 'No')     This is valid syntax, but every record is returning 'No', when there should be 'Yes' also.    I tried:    IF(CONTAINS(ProductHierarchy__r.NRElement__r.Name, "Water"), "Yes", "No")    as well, which was valid, but gave the same unexpected results   

5 Antworten
  1. 16. Mai, 18:34

    I should point out that the record type I am wanting to display a value against is one ('Site'), but the value/result is coming from 'Asset'.  So, If Site record 'A' contains an Asset Record A, B & C which is water related, then Site record A will contain water.  If Site 'A' doesn't contain any Asset records in it that are water related, then the result will be 'no'. 

    I should point out that the record type I am wanting to display a value against is one ('Site'), but the value/result is coming from 'Asset'.image.png

     

    My thought was I could create a formula lookup on asset record type, and then create another formula to display on site that looked up the value on assets within, but frustratingly salesforce won't let you create formulas looking up other formulas

0/9000

Hi fellow Trailblazers,    I'm attempting to create a validation rule that will fire if   1) the opportunity record type is not one particular type,  2) the amount field on an opportunity is null or 0,  and  3) the stage is one of four values    I inputted this text:  "AND( RecordType.Id<>"0120b000000udB0AAI",  OR( Amount =0,ISNULL(Amount)=TRUE),  OR( ISPICKVAL(StageName,"Pledged"),  ISPICKVAL(StageName,"Received"),  ISPICKVAL(StageName,"Awarded - Open"),  ISPICKVAL(StageName,"Awarded - Closed"))  )"    The validation rule is firing on opportunities that ARE the record type I specified in the first condition. Does anyone know why this is happening? Please help!   

4 Antworten
  1. 14. Mai, 19:38

    a few things:  

     

    First: Validation Rule Formulas can't read the full 18 character ID, they can only the 15 character ID  

     

    Second:  Don't use hard coded ID in Formulas, use RecordType Name or DeveloperName   

     

    Third:  Don't use ISNULL, that Function has been deprecated by Salesforce like 10+ years ago   

     

    I would write it like this

    AND(

    RecordType.Name <> 'Hi My Name Is',

    OR(

    Amount = 0,

    ISBLANK(Amount)

    ),

    CASE( StageName,

    'Pledged', 1,

    'Received', 1,

    'Awarded - Open', 1,

    'Awarded - Closed', 1,

    0 ) = 1

    )

0/9000

I'm trying to do a summary-level formula to work out an the average individual call rate per day, but the grand total row defaults to a sum

not an average, and I'm encountering validation errors whenever I try to do something. 

 

Screenshot 1 shows the basic call rate formula - number of rows/entries divided by the number of unique dates - fine. But in screenshot 3 you can see this

sums

in the grand total, whereas I want the average across the 7 users. 

 

Screenshot 2 I've tried to divide this by the number of Call Owners Unique - which gives the same numbers on an individual row level (dividing by 1), but dividing by 7 is giving the incorrect answer of 4.13 (the average of those numbers should be 8.47). I suspect the issue is to do with the "UNIQUE" criteria attached to the Call Date field - but if I remove this I get a validation error. 

 

ChatGPT suggests that creating a "Call Count" field within the Call object (where every entry just equals 1) will fix this issue as I can use for summing up the rows, but I don't understand how a SUM of this custom call count field would behave differently to "RowCount". 

 

Any advice greatly appreciated! 

Summary Level Formula - Grand Total?

 

 

callrate2.png

 

 

callrate1.png

 

 

2 Antworten
0/9000

Hi all, I created a field on tasks that is a checkbox to flag if an activity was created within business hours. Our business hours are 8am - 10pm EST. I am using the formula below, and this is working to pull tasks created between 8am and 8pm, however, because we are in EST and offset by 4, the value would go beyond 24 and not working. Anyone know how to flag tasks created between 8am and 10pm EST?? Thank you!!!!

 

(VALUE(LEFT(MID(TEXT(CreatedDate), 12, 5), 2)) + VALUE(RIGHT(MID(TEXT(CreatedDate), 12, 5), 2))/60) >= 12 && (VALUE(LEFT(MID(TEXT(CreatedDate), 12, 5), 2)) + VALUE(RIGHT(MID(TEXT(CreatedDate), 12, 5), 2))/60) <= 24

1 Antwort
  1. 11. Mai, 16:22

    Hi Meg, 

     

    This is due to the fact that string formula cannot deal with the UTC wrap-around. It would be simpler to shift the time prior to evaluating the hour. 

     

    Consider this: 

     

    HOUR(TIMEVALUE(CreatedDate - (4/24))) >= 8 && 

    HOUR(TIMEVALUE(CreatedDate - (4/24))) < 22 

     

    Why does it work? 

    Time Shifted: Shifting by 4/24 shifts UTC time to EST. 

    Error-Free: Salesforce takes care of the 24-hour wrapping internally; therefore, no errors occur at midnight. 

     

    Easier: Simply use the HOUR function rather than complicated string manipulation.

0/9000

Hello, 

 

I have a formula which currently calculates the difference between the Last Modified Date and the Date field (a custom Date field). Formula is: 

 

DATEVALUE(LastModifiedDate) - Date__c 

 

Formula is correct, so for the below record field "Gap Days" is calculated as follows: 

 

Gap Days= LastModifiedDate - Date__c= 8/5/26 - 28/5/26 = -20 

 

The "issue" is i am scratching my head whether it should be negative or just indicate the number "20". 

 

Question: Should i change it to "Date__c - LastModifiedDate" , so that it isn't negative? The Date field is a the date a salesperson has has a meeting so i'm guessing the LastModified will always be after the Meeting Date - Am i missing anything? 

Formula Question/ Clarification

 

2.png

 

  

 

#Formulas

2 Antworten
  1. 10. Mai, 17:16

    In any case, everything will depend on what you need the value of the 'Gap' to reflect. In case you need to determine how many days have gone after the meeting, then your formula is fine, only the returned result should be positive, otherwise you can simply move the dates in your formula around. In case you need just a positive value irrespective of what date is earlier, you can simply put an ABS function around your formula: 

     

    ABS(DATEVALUE(LastModifiedDate) - Date__c) 

     

    Now you won't need to change anything if someday a meeting date changes position!

0/9000

Hi all, 

 

im hoping someone may be able to assist, im trying to write a formula that'll calculate the amount of hours between two date time stamps in my org (Case on hold - Internal and Case off hold - Internal)

 

this is so that we can moniter our KPIs, there are a few consideration i have to consider which are as follows:

 - exclude saturdays and sundays from the calculation so if we have 2 weekends inbetween the two dates itll remove 96 hours from the calculation) 

- we have a cut off of 17:00 so if theyre marked as on hold after then, then itll start the hours counting from the following working day. 

 

i have tried various formulas but to no avail, i have even set up business hours within the sandbox but cannot seem to get anything to work how i want it to. 

 

any help is greatly appreciated. 

 

Kind regards

12 Antworten
  1. Eric Praud (Activ8 Solar Energies) Forum Ambassador
    15. Jan. 2025, 16:13

    Apologies, I forgot to reply.

     

    I see a typo in my formula, there is a "8*60+300" that should be "8*60+30":

    ((DATEVALUE(date_time_2__c )-DATEVALUE(date_time_1__c )-1)*8.5

    +

    ((17*60+00)

    -

    (

    IF(CASE(WEEKDAY(DATEVALUE(date_time_1__c)),1,1,7,1,0)=1,8*60+30,

    MIN(17*60+00,

    MAX(HOUR(TIMEVALUE(date_time_1__c ))*60+MINUTE(TIMEVALUE(date_time_1__c )),8*60+30)))))/60

    +

    (

    IF(CASE(WEEKDAY(DATEVALUE(date_time_2__c)),1,1,7,1,0)=1,17*60+0,

    MIN((MAX(8*60+30,HOUR(TIMEVALUE(date_time_2__c ))*60+MINUTE(TIMEVALUE(date_time_2__c )))),(17*60+0)))

    -

    (8*60+30))/60)

    -

    8.5*(

    FLOOR((DATEVALUE(date_time_2__c)- DATEVALUE(date_time_1__c))/7)*2

    +

    IF(AND(WEEKDAY(DATEVALUE(date_time_1__c))=1, WEEKDAY(DATEVALUE(date_time_2__c))<>7),1,

    IF(CASE(WEEKDAY(DATEVALUE(date_time_1__c)),1,8,WEEKDAY(DATEVALUE(date_time_1__c)))>CASE(WEEKDAY(DATEVALUE(date_time_2__c)),1,8,WEEKDAY(DATEVALUE(date_time_2__c))),2,

    IF(OR (WEEKDAY(DATEVALUE(date_time_2__c))=7, WEEKDAY(DATEVALUE(date_time_1__c))=1),1,

    IF(OR (WEEKDAY(DATEVALUE(date_time_2__c))=1, WEEKDAY(DATEVALUE(date_time_1__c))=7),2,

    0))))

    )

    Also, it will return 0.25 in your example since it is only a quarter of an hour since 8.30 on the 14th. a quarter of 1(hour) returns 0.25 in my formula

0/9000