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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...