Splunk Search

splunk eval case statement compare the case-sensitive value or case-insensitive

Chandras11
Communicator

Hi Everyone,

I have a very small conceptual doubt. Does the eval case do case insensitive compare or will it compare the exact values (Case sensitive only)? I need a case-insensitive comparison here.

LINE_CODE value examples:- AMx05323, amy4bl124, bmz4265678 etc. If the first Character is a or A (case insensitive "a", it should return Atlanta otherwise it should return Other.

Do the following 2 statements will provide the same results or different.

| eval REGION_ID = (substr(LINE_CODE,1,1)="a") OR (substr(LINE_CODE,1,1)="A")) ,"Atlanta", 1=1,"Other") 

and

| eval REGION_ID = substr(LINE_CODE,1,1)="a"  ,"Atlanta" , 1=1," Other") 

Thanks for your time.

0 Karma
1 Solution

FrankVl
Ultra Champion

That's easy enough to test:

| makeresults
| eval LINE_CODE="Abcd"
| append [
| makeresults
| eval LINE_CODE="abcd"
]
| eval REGION_ID = case(substr(LINE_CODE,1,1)="a","Atlanta", 1=1," Other")

Which results in:

LINE_CODE   REGION_ID
Abcd    Other
abcd    Atlanta

Conclusion: it is case sensitive. To make it insensitive, simply cast to lowercase before testing:

| eval REGION_ID = case(lower(substr(LINE_CODE,1,1))="a","Atlanta", 1=1," Other")

View solution in original post

woodcock
Esteemed Legend

By default, the lookups are case-insensitive but if you create a Lookup definition mapped to your Lookup file then you can specify MANY things, including case-sensitive vs. case-insensitive and also WILDCARD and CIDR based fields.

0 Karma

FrankVl
Ultra Champion

That's easy enough to test:

| makeresults
| eval LINE_CODE="Abcd"
| append [
| makeresults
| eval LINE_CODE="abcd"
]
| eval REGION_ID = case(substr(LINE_CODE,1,1)="a","Atlanta", 1=1," Other")

Which results in:

LINE_CODE   REGION_ID
Abcd    Other
abcd    Atlanta

Conclusion: it is case sensitive. To make it insensitive, simply cast to lowercase before testing:

| eval REGION_ID = case(lower(substr(LINE_CODE,1,1))="a","Atlanta", 1=1," Other")

Chandras11
Communicator

Perfect, thanks for the explanation. is there any way to remove if there is a blank space in from of LINE_CODE for example:- LINE_CODE = " Abrd"

0 Karma

Chandras11
Communicator

Thanks a lot.. It looks like the excel TRIM function. 🙂 I can go ahead easily now

0 Karma

FrankVl
Ultra Champion
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Painting a Clearer Picture: Creating Cross-Domain Visibility with AI Canvas

    Thursday, June 25, 2026  |  11AM PDT / 2PM EDT  Duration: 1 Hour (Includes live Q&A) Register to ...

Analytics Workspace deprecation

As of Splunk Cloud Platform 10.4.2604 and Splunk Enterprise 10.4, Analytics Workspace is now deprecated. ...

Splunk Developer Day Recap: Building, Publishing, and Growing on the Splunk Platform

Splunk Developer Day brought the Splunk developer community together for a practical look at what it means to ...