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
Syed AsfaanSyed Asfaan 

Automatically get Previous dates value to present day.


I want Previous days value to automatically subtract with present days value.

Example: It's a car related app, where I need to track daily Kilometres odometre reading. 
"Opening day reading - closing day" reading is to be monitored daily.

Where todays closing reading should be tomorrow opening reading automatically..

So once user is on Board, you just need to enter opening reading once and daily user must only enter closing reading.

So only once closing readng is entered, automatically the formula should detect previous days closing reading.

Sorry for the long and complicated explanation for the question, just trying to explain how the forumale should work, accordingly you all can suggest...

Bryan Leaman 6Bryan Leaman 6

Sounds like you'll need to create a prior day reading field and have a nightly batch process that copies the closing day reading to this new prior day reading field. Then you can create a formula that simply subtracts the prior day reading from the closing day reading. If you need to also calculate the differential on that first day as well, then the formula could do something like:

Closing_Day_Reading__c - NULLVALUE(Prior_Day_Reading__c, Opening_Day_Reading__c)

If you want nothing to show until the first prior day reading has been entered, then you need to condition the formula:

IF (NOT(ISBLANK(Closing_Day_Reading__c)), Closing_Day_Reading__c - NULLVALUE(Prior_Day_Reading__c, Opening_Day_Reading__c), NULL)

Syed AsfaanSyed Asfaan
Hi Bryan, thanks for replying.
i Understoof the formula, but confused with the field names.
My formula is    Sale = Closing Reading - Opening reading
Have these 3 fields created where Sale is the formula field.

I want Opening reading to be automatically shown as Yestedays/Previous days Closing reading.
I am having a Date field also to be selected every day. 

Pls suggest.