Splunk Search

How to multiply column values?

rslama
Path Finder

The way I do this in excel is by using the formula "=PRODUCT(C2*C3*C4*C5)"
How can I do that in Splunk?

Ideally, I want to do something like this:
search stuff

| foreach group
     [eval crossyield=PRODUCT(yield)]

alt text

0 Karma
1 Solution

kamlesh_vaghela
SplunkTrust
SplunkTrust

@rslama

You can achieve this scenario by playing with some awesome SPL commands. Can you please try this?

YOUR_SEARCH | eventstats list(Yield) as crossYield by Group | nomv crossYield | map search="| makeresults | eval s=\"$crossYield$\", s=split(s,\" \"), a=1 | mvexpand s | accum a | eval val_{a}=s | stats values(val_*) as val_* | eval crossYield=round(1,10) | foreach val_* [ eval crossYield=exact(crossYield * '<<FIELD>>') ] | eval Group=\"$Group$\",SubGroup=\"$SubGroup$\",Yield=\"$Yield$\" | table Group SubGroup Yield crossYield "

Sample Search:

| makeresults | eval _raw="Group    SubGroup    Yield
A   A.0 0.9
A   A.1 0.99
A   A.2 0.75
A   A.4 0.8
B   B.1 1
B   B.2 0.9
B   B.11    0.3
C   C.5 1
C   C.19    0.8" | multikv | table Group SubGroup Yield | eventstats list(Yield) as crossYield by Group | nomv crossYield | map search="| makeresults | eval s=\"$crossYield$\", s=split(s,\" \"), a=1 | mvexpand s | accum a | eval val_{a}=s | stats values(val_*) as val_* | eval crossYield=round(1,10) | foreach val_* [ eval crossYield=exact(crossYield * '<<FIELD>>') ] | eval Group=\"$Group$\",SubGroup=\"$SubGroup$\",Yield=\"$Yield$\" | table Group SubGroup Yield crossYield "

Thanks

View solution in original post

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@rslama

You can achieve this scenario by playing with some awesome SPL commands. Can you please try this?

YOUR_SEARCH | eventstats list(Yield) as crossYield by Group | nomv crossYield | map search="| makeresults | eval s=\"$crossYield$\", s=split(s,\" \"), a=1 | mvexpand s | accum a | eval val_{a}=s | stats values(val_*) as val_* | eval crossYield=round(1,10) | foreach val_* [ eval crossYield=exact(crossYield * '<<FIELD>>') ] | eval Group=\"$Group$\",SubGroup=\"$SubGroup$\",Yield=\"$Yield$\" | table Group SubGroup Yield crossYield "

Sample Search:

| makeresults | eval _raw="Group    SubGroup    Yield
A   A.0 0.9
A   A.1 0.99
A   A.2 0.75
A   A.4 0.8
B   B.1 1
B   B.2 0.9
B   B.11    0.3
C   C.5 1
C   C.19    0.8" | multikv | table Group SubGroup Yield | eventstats list(Yield) as crossYield by Group | nomv crossYield | map search="| makeresults | eval s=\"$crossYield$\", s=split(s,\" \"), a=1 | mvexpand s | accum a | eval val_{a}=s | stats values(val_*) as val_* | eval crossYield=round(1,10) | foreach val_* [ eval crossYield=exact(crossYield * '<<FIELD>>') ] | eval Group=\"$Group$\",SubGroup=\"$SubGroup$\",Yield=\"$Yield$\" | table Group SubGroup Yield crossYield "

Thanks

0 Karma

rslama
Path Finder

Thank @kamlesh_vaghela
this works perfectly. but how do I change limit=0?
I am only getting 10 results in my statistics table.

0 Karma

rslama
Path Finder

NVM, I found the answer. I needed to set maxsearch

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, ...