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
Dave_KellerDave_Keller 

How do I use this_week, last_week, etc in calculated fields?

I'm trying to get totals of opportunity amounts using "this week", "last week", "n weeks ago" in new custom fields, and then roll up the totals in summary reports. However, I get errors saying these don't exist, either with the underscore or without. How can I use them in calculated fields?

 

A typical use case would be:

 

IF(CloseDate = Last_Week,Amount,0)    or  IF(CloseDate = 3 weeks ago,Amount,0)

 

For me, TODAY() and Now() work, but not other literals. 

 

Guidance, please...

_Prasu__Prasu_

I am not sure they are present or can be used in Formula field. You can use following link for possible function whichs can be use in building formula field.

https://na1.salesforce.com/help/doc/en/salesforce_formulas_cheatsheet.pdf

_Prasu__Prasu_

Checkout Examples of advance formula field on following link, may give you solution

http://www.salesforce.com/us/developer/docs/usefulFormulaFields/index.htm

mukesh guptamukesh gupta
Hi 

THIS_WEEK  :- Starts 00:00:00 on the most recent first day of the week before the current day and continues for seven full days. Your locale determines the first day of the week.
SELECT Id FROM Account WHERE CreatedDate < THIS_WEEK

LAST_WEEK:- Starts 00:00:00 on the first day of the week before the most recent first day of the week and continues for seven full days. Your locale determines the first day of the week.
SELECT Id FROM Account WHERE CreatedDate > LAST_WEEK

if you fond this useful then, PLEASE MARK AS A BEST ANSWER!!

​​​​​​​Regards
Mukesh