Splunk Search

Can I combine eval & latest?

varunapj
New Member

Hi,

I have scenario were i have the record sets and the number & name will keep changing based on the status
Table : No, Name,Status,Product,ID
Status can be (P-pending,C-cancelled, A-Accepted)
So, if i have to eliminate the duplicate should i use like this
-->index="XXXXX" PRODUCT=O1| dedup PCN |stats count(eval(STATUS="A")) AS APPROVED
or should I use latest ?

Thanks in advance.

Tags (2)
0 Karma
1 Solution

HiroshiSatoh
Champion

Specifically, what do you want to count up?
If the status is only the number of A, you can do it.

index="XXXXX" PRODUCT=O1 STATUS="A"| dedup PCN |stats count AS APPROVED 

View solution in original post

0 Karma

varunapj
New Member

Thank you @niketnaily @HiroshiSatoh @mayurr98
Status: A -Approved,C-Cancelled & P- Pending

Please find the mock table below and my requirement is to get the count of Approved records and the below will work

index="XXXXX" PRODUCT=O1 STATUS="A"|stats dc(PCN) AS APPROVED
or
index="XXXXX" PRODUCT=O1| dedup PCN |stats count(eval(STATUS="A")) AS APPROVED

However, if i use dedup on P to find the pending status, that can be wrong as the pending records will be moved to cancelled or approved or declined. So, i was wondering whether i can use latest based on the ID and the count the status .

PCN NameProduct ID Status
123 Varun 01 A
121 Arun 01 C
123 Varun 01 P
121 Arun 01 P
124 Don 01 D
124 Don 01 P


Hope i am not confusing.

0 Karma

mayurr98
Super Champion

do you want something like distinct count of PCN where Status=A?
Also, can you tell me what is PCN?

You can try something like this

index="XXXXX" PRODUCT=O1 STATUS="A"|stats dc(PCN) AS APPROVED

let me know if this helps!

0 Karma

niketn
Legend

@varunapj, I think what would help is, if you can post data sample of what you have and what is the output you want. You can mock/anonymize any sensitive information.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

HiroshiSatoh
Champion

Specifically, what do you want to count up?
If the status is only the number of A, you can do it.

index="XXXXX" PRODUCT=O1 STATUS="A"| dedup PCN |stats count AS APPROVED 
0 Karma
Get Updates on the Splunk Community!

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

New Release | Splunk Cloud Platform 10.1.2507

Hello Splunk Community!We are thrilled to announce the General Availability of Splunk Cloud Platform 10.1.2507 ...

🌟 From Audit Chaos to Clarity: Welcoming Audit Trail v2

🗣 You Spoke, We Listened  Audit Trail v2 wasn’t written in isolation—it was shaped by your voices.  In ...