Splunk Search

How to iterate a value in ColumnA through all values in ColumnB doing an eval division with the output in ColumnC?

mrncst
Engager

Hello folks,

I have a stats result with two columns:

Column A - only one result in the first line
Column B - 8 lines of different values

I'd like to iterate the value in Column A through all the values in Column B, doing a eval division, that would be returned in a third column.
For example: columnA.firstline/columnB.firstline, columnA.secondline/columnB.firstline, ...

Is it possible?

Thanks in advance!

Tags (3)
0 Karma

ramdaspr
Contributor

If the column isnt multivalues, you can use streamstats to capture what the first value of the column is and use it to calculate the new column.

... | streamstats first(columnA) as div | eval result=columnB/div | table columnA, ColumnB,result
0 Karma

somesoni2
Revered Legend

I am guessing ColumnB is a multivalued field (output of aggregation commands like values/list). Here is what you can try

your base search giving single valued field ColumnA and multivalued field ColumnB | eval ColumnB_Orig=ColumnB| mvexpand ColumnB | eval ColumnC=round(ColumnA/ColumnB,2) | rename ColumnB_Orig as ColumnB| table ColumnA, ColumnB, ColumnC
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, ...