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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...