Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
ShowAll Questionssorted byDate Posted
JustD

# Checking percentage field for 100% - not working

Hi,

Tearing my hair out over this one.  I need a simple validation rule to check that a percentage field's value is <> 100%.

This is my rule:

Percentage_Complete__c = 100

This is the result from the debug log when the field has value of 100

20:12:51.054 (54955000)|VALIDATION_FORMULA|Percentage_Complete__c = 100|Percentage_Complete__c=100
20:12:51.054 (54963000)|VALIDATION_PASS

And when the value is 90

20:23:47.056 (56888000)|VALIDATION_FORMULA|Percentage_Complete__c = 100|Percentage_Complete__c=90
20:23:47.056 (56903000)|VALIDATION_PASS

How can it pass with both 100 and 90?

But if I change the rule to:

Percentage_Complete__c < 100

When the value is 100 this is the result

20:27:47.075 (75783000)|VALIDATION_FORMULA|Percentage_Complete__c < 100|Percentage_Complete__c=100
20:27:47.075 (75798000)|VALIDATION_FAIL

I get this when the value is 90

20:26:25.055 (55444000)|VALIDATION_FORMULA|Percentage_Complete__c < 100|Percentage_Complete__c=90
20:26:25.055 (55456000)|VALIDATION_FAIL

Again how can this fail with both 100 and 90?

Any help will be much appreciated.

Thanks
Derek

53048

Best Answer chosen by Admin (Salesforce Developers)
JustD

Thanks for the replies.  But I actually managed to fix this myself (after spotting a relevant comment in another post).

In validation rules the value of a percentage field is expresses as 1 for 100%, 0.9 for 90% and so on.

Therefore the correct syntax for the rules in question is:

Percentage_Complete__c = 1

Avidev9

May be you need to do "==" instead of "=" ?

First one is comparison operator and second one is assignment. So rule should be

`Percentage_Complete__c == 100`

KT1
When do you want it to Fire, when it is 100% or when it is less than 100%? Also, what kind of a field is "Percentage Complete"?
JustD

Thanks for the replies.  But I actually managed to fix this myself (after spotting a relevant comment in another post).

In validation rules the value of a percentage field is expresses as 1 for 100%, 0.9 for 90% and so on.

Therefore the correct syntax for the rules in question is:

Percentage_Complete__c = 1

This was selected as the best answer
KT1

That is what I was going to come back with if you said that it was a Percentage field.