Splunk Search

Searching a lookup

Siddharthnegi
Contributor

I have this lookup

Siddharthnegi_0-1705395632145.png

I want the total count when the timeval is latest. (in this case 2023) any solution

0 Karma

PickleRick
SplunkTrust
SplunkTrust

If you want to just get some statistical report on data read from your lookup, use the inputlookup command.

Like

| inputlookup mylookup | stats count

will give you number of rows in your lookup. You can do any operation on fields read from the lookup that you would normally do in a "normal" event search.

Siddharthnegi
Contributor

thanks for the reply but  I want the total count when the timeval is latest. (in this case 2023), so according to my lookup result should be 2. with BIE count is 0 and  RAD count is 2 so 0+2=2. Hope this helps in understanding

0 Karma

PickleRick
SplunkTrust
SplunkTrust

And what have you tried so far? And how the results weren't meeting your expectations?

0 Karma

Siddharthnegi
Contributor

if i try to find count i am only getting count of either BIE or RAD . But I want count of both combined .

0 Karma

PickleRick
SplunkTrust
SplunkTrust

What is your search then?

0 Karma

Siddharthnegi
Contributor

| inputlookup abc.csv
| eval CompanyCode="DSPL"
| eventstats values(CompanyCode) as CompanyCode
| eval 3Let=case(CompanyCode == "DSDE", "BIE", CompanyCode == "DSDE-AS", "PUT", CompanyCode == "DSDE-FS", "STL", CompanyCode == "CSDE", "DAR", CompanyCode == "DSPL", "RAD", CompanyCode == "DSMX", "QUE", CompanyCode == "DSUS", "SSC")
| where '3Let'='place'
| sort - timeval
| table count timeval
| head 1
|appendpipe [stats count | where count==0
| eval timeval=strftime(now(),"%Y") | where count==0]

0 Karma

PickleRick
SplunkTrust
SplunkTrust

OK. We're getting somewhere 🙂

| inputlookup abc.csv
| eval CompanyCode="DSPL"
| eventstats values(CompanyCode) as CompanyCode
| eval 3Let=case(CompanyCode == "DSDE", "BIE", CompanyCode == "DSDE-AS", "PUT", CompanyCode == "DSDE-FS", "STL", CompanyCode == "CSDE", "DAR", CompanyCode == "DSPL", "RAD", CompanyCode == "DSMX", "QUE", CompanyCode == "DSUS", "SSC")
| where '3Let'='place'

OK. I assume this produces your data set and it works pretty OK.

But now if you want to have _all_ events for which a particular field has a value which is max of all possible, you have several options available (for example using subsearches) but the easiest one will be to add an additional field which tells you which value is the max year value. For this we use eventstats.

| eventstats max(timeval) as maxyear

Now you have an additional field telling you which year is the max year. So now just filter your values to only leave those where your timeval is equal to that maxyear

| where timeval=maxyear

And you should be all set 🙂

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!

SOK it to Me: Top 3 Benefits of Using Splunk Operator on Kubernetes that’ll Make ...

    Thursday, July 9, 2026  |  11:00AM–12:00PM PDT Duration: 1 hour (includes Q&A) Managing can feel like a ...

Upgrade Prep for 10.4, Network Observability Deep Dives, and More from Splunk Lantern

Splunk Lantern is Splunk’s customer success center that provides practical guidance from Splunk experts on key ...

Splunk Developer Day announcements: AI agents, MCP tools, Forecasting, and Custom ...

Splunk Developer Day was packed with product and platform updates for developers building in the AI ...