Splunk Search

How to use substr in an eval with if

phamxuantung
Communicator

I try to use the query

 

eval ID = if(ORG="MC",ID=substr(ID,-6),0)

 

Basically, I want in my result, if ORG="MC", I want to extract the last 6 characters of the field ID that go with it, otherwise stay the same. But the result table always show ID as False if ORG="MC"

How do I fix my query or have to go the other way?

Labels (2)
0 Karma

manjunathmeti
Champion

hi @phamxuantung,

Fixed the query:

| eval ID=if(ORG="MC", substr(ID, -6), ID)

 

0 Karma
Get Updates on the Splunk Community!

Accelerating Observability as Code with the Splunk AI Assistant

We’ve seen in previous posts what Observability as Code (OaC) is and how it’s now essential for managing ...

Integrating Splunk Search API and Quarto to Create Reproducible Investigation ...

 Splunk is More Than Just the Web Console For Digital Forensics and Incident Response (DFIR) practitioners, ...

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...