Splunk Search

Help with subsearch eval function with where clause

ND
Path Finder

Hi All,

I want help to use where clause in eval command:

below is lookup data:

ID  expense year

1     10          2021

2     20          2020

3     10          2021

4     30          2019

5     20          2020

eval a = sum(expense) by ID, year where ID IN(1,3)

eval b= sum(expense) by ID, year  where ID IN(2,4)

eval c= sum(expense) by ID, year where ID IN(1,2,3,4)  [excluding few ID's from the search]

 

can someone help me to get this. I tried join to have these values as a subsearch but not able to get it.

 

thanks.

 

Labels (4)
0 Karma
1 Solution

ND
Path Finder

@ITWhisperer  thanks for the solution. it solved my query.

View solution in original post

0 Karma

ND
Path Finder

@ITWhisperer  thanks for the solution. it solved my query.

0 Karma

mayurr98
Super Champion

Could you please paste the result of the output that you want?

The question doesn't make sense to me, when you say sum(expense) by ID, it means sum(expense) by distinct ID in splunk language and it will always be the value of expense as shown in the input table.

Please tell us the output result in tabular format that you want.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| eval group_a=if(ID IN (1,3),expense,null())
| eval group_b=if(ID IN (2,4),expense,null())
| eval group_c=if(ID IN (1,2,3,4),expense,null())
| stats sum(group_a) as a sum(group_b) as b sum(group_c) as c by year
0 Karma
Get Updates on the Splunk Community!

Technical Workshop Series: Splunk Data Management and SPL2 | Register here!

Hey, Splunk Community! Ready to take your data management skills to the next level? Join us for a 3-part ...

Spotting Financial Fraud in the Haystack: A Guide to Behavioral Analytics with Splunk

In today's digital financial ecosystem, security teams face an unprecedented challenge. The sheer volume of ...

Solve Problems Faster with New, Smarter AI and Integrations in Splunk Observability

Solve Problems Faster with New, Smarter AI and Integrations in Splunk Observability As businesses scale ...