Splunk Search

How do I get over conditional functions formatting?

Stives
Engager

Hello community,

like to ask for support to get over conditional formatting. I have 3 different products in a group. Product A, B and C and I need to add for each of them a different formula (compensation factor) e.g..

PRODUCT A = group/3.33*100 

PRODUCT B = group/3.061*100

PRODUCT C = group/3.0*100

I could only do this when I create search only for one PRODUCT. But how to include all the PRODUCTS with different formulas (compensation factors) ?

| where group="PRODUCT_A"
| eval ProductGroup=group/3.33*100

Thanks

Labels (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

A case function should do the job.

| eval ProductGroup = case(product=A, group*100/3.33, product=B, group*100/3.061, product=C, group*100/3.0)

 

---
If this reply helps you, Karma would be appreciated.

View solution in original post

0 Karma

Stives
Engager

Hello Rich, 

thanks for message. Finally I´ve managed apply case function and resolved the issue.
Thanks for support.

BR

0 Karma

richgalloway
SplunkTrust
SplunkTrust

If your problem is resolved, then please click one of the "Accept as Solution" buttons to help future readers.

---
If this reply helps you, Karma would be appreciated.
0 Karma

marysan
Communicator


|eval ProductGroup=case(group=="PRODUCT_A",group/3.33*100 ,group=="PRODUCT B",group/3.061*100,group=="PRODUCT C",group/3.0*100)

Tags (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

This looks like a faithful interpretation of the OP's question, but won't work because if the group field is a string (contains "PRODUCT_x") then it cannot be divided by a number.

---
If this reply helps you, Karma would be appreciated.
0 Karma

Stives
Engager

I want eval a row called RML = case (in the row "group", for a VALUE A divided by 3.33*100, in the row "group", for a value B divided by 3.061*100, in the row "group", for a VALUE C divided by 3.0*100)

0 Karma

Stives
Engager

Hello, not really as the formula does not work unfortunately.

I want eval a group = case (in the row "group", for a VALUE A divided by 3.33*100, in the row "group", for a value B divided by 3.061*100, in the row "group", for a VALUE C divided by 3.0*100)

Thanks

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Please elaborate on "does not work".  What results do you get and how do they not meet expectations?

It might help if you shared actual (sanitized) events.

---
If this reply helps you, Karma would be appreciated.
0 Karma

richgalloway
SplunkTrust
SplunkTrust

A case function should do the job.

| eval ProductGroup = case(product=A, group*100/3.33, product=B, group*100/3.061, product=C, group*100/3.0)

 

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...