+ Start a Discussion
Sami ShakithSami Shakith 

Compare a integer with picklist value in formula field.

Hi all,

I want to compare a integer value with picklist field. while doing im getting "Error: Incorrect parameter type for function 'ISPICKVAL()'. Expected Text Literal, received Number" like this. Please need expert help
Best Answer chosen by Sami Shakith
Sachin KadianSachin Kadian
Try this, its working for me.
IF(VALUE(TEXT(Date__c)) == DAY(TODAY()) , TRUE,FALSE)

 

All Answers

Miika RintakoskiMiika Rintakoski
Hi Sami,

Make sure you wrap the number within single quotes like this:

ISPICKVAL( Object__c.Field__c , '1')

Let me know if you found this helpful!

Miika
Sachin KadianSachin Kadian
You can do it like this.

IF(ISPICKVAL(test__c, '1'),'1','2')
Sami ShakithSami Shakith
Hi miika & sachin,

Thank you so much. It works.
Sachin KadianSachin Kadian
OR you can convert picklist value to NUMBER like this 

IF(VALUE(TEXT(test__c)) == 1,'1','2')

here test__c is picklist field.
Sami ShakithSami Shakith

My formula field is like that

IF( ISPICKVAL(Date__c, ' DAY( TODAY() )'), 'true', 'false')

Every time its update false value only. I gave 8 in Date__c field it returns false value but that day(today()) returns 8 in another formula field. Is anything wrong in my formula?
 

Sachin KadianSachin Kadian
Try this, its working for me.
IF(VALUE(TEXT(Date__c)) == DAY(TODAY()) , TRUE,FALSE)

 
This was selected as the best answer
Sami ShakithSami Shakith
Thank Sachin it works. But Why that formula doesnt work?
Sachin KadianSachin Kadian
HI Sami, 

According to official docs here 

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_variables_functions.htm

"ISPICKVAL(picklist_field, text_literal)and replace picklist_field with the merge field name for the picklist; replace text_literal with the picklist value in quotes. text_literal cannot be a merge field or the result of a function."

So it can not be a result of other function.

If it solved your problem, please mark it as SOLVED so that it can help others.
Sami ShakithSami Shakith
Thanks a lot Sachin. Very cleared now.