Splunk Dev

USE AND Operator in IF or CASE statement

kumagaur
New Member

I have one lookup in which there is a field which consist
Team Member
A1
A2
A3
A4
A5
A6
A7
Now,If
TeamMember=(A1 OR A2) AND A4 AND A7 then print Aseries
TeamMember=(A1 OR A2) and A5 AND A6 then print Bseries

I tried |eval Team=if((con1=="A1 OR con1=A2)"AND con1=="A4" AND con1=A7,Aseries,Other)

I used case as well but no luck.

Tags (1)
0 Karma
1 Solution

woodcock
Esteemed Legend

Maybe like this:

Your Base Search Here
| appendpipe [|inputlookup TeamMember.csv | stats values(TeamMember) AS con1]
| eval Team=if(((con1=="A1" OR con1=="A2") AND con1=="A4" AND con1=="A7"), "Aseries", "Bseries")

View solution in original post

0 Karma

woodcock
Esteemed Legend

Maybe like this:

Your Base Search Here
| appendpipe [|inputlookup TeamMember.csv | stats values(TeamMember) AS con1]
| eval Team=if(((con1=="A1" OR con1=="A2") AND con1=="A4" AND con1=="A7"), "Aseries", "Bseries")
0 Karma

vishaltaneja070
Motivator

Try this:
| eval Team= if((con1== "A1" OR con1=="A2") AND con1=="A4" AND con1="A7", Aseries, Other)

0 Karma

renjith_nair
Legend

@kumagaur ,
Do you have multiple values of con1 in a single event ? If not AND condition will not work. Do you have some sample events ?

Happy Splunking!
0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

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

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...