Splunk Search

Replace string in column A based on query of multiple columns

olivne
Engager

Hi

I have this table:

 

customer | city
A        | NY
B        | NY
A        | LA

 

and I want to replace the value in `customer` to B only when it's  `customer == A` and `city == LA`. 
I checked this solution but it resulted in deleting all entries beside the one I replaced.
```

eval customer=if(match(customer, "A"), "LA", customer)

 

Labels (4)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

So you want

customer | city
A        | NY
B        | NY
B        | LA

 If so, try this

eval customer=if(match(customer, "A") AND match(city, "LA"), "B", customer)

 

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

So you want

customer | city
A        | NY
B        | NY
B        | LA

 If so, try this

eval customer=if(match(customer, "A") AND match(city, "LA"), "B", customer)

 

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