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
PetyaPetya 

If a value is reached the 0, don't allow any negative values

Hello 

I try to define a formula, which counts every time if a condition is true -1 backwards. I don’t want to have any negative values, if i reached 0, I want to stay by 0 and don’t want to count to -1, -2 ... and so on.

This is my formula

IF( ISNULL(Counter__c) ,0, Counter__c - 1)

The problem is that with this formula I stil have negative values.

Any Ideas?

 


 

Best Answer chosen by Admin (Salesforce Developers) 
PetyaPetya

thank you very much :) !

All Answers

Jake GmerekJake Gmerek

This should do the trick, if Counter__c is negative, 0, or null it should set it to 0, else use Counter__c-1:

 

 

IF (OR (counter__c <= 0, ISNULL(Counter__c)), 0, Counter__c -1)

 

Let me know if it does not work.

PetyaPetya

thank you very much :) !

This was selected as the best answer
sfdcfoxsfdcfox

A more compact version that would also work is:

 

MAX(Counter__c, 0)

 

PetyaPetya

many thanks :)