How to use eval with IF? (2024)

@LH_SPLUNK, ususally source name is fully qualified path of your source i.e. besides the file name it will also contain the path details. So, your condition should not find an exact match of the source filename rather than it should be a pattern of ending with filename. Following is a run anywhere example illustrating the difference in your approach vs regular expression pattern match for source using match()

| makeresults| eval source="source_a.csv,source_b.csv,/blah/blah/source_a.csv,/blah/blah/source_b.csv"| makemv source delim=","| mvexpand source| eval A=if(source == "source_a.csv", "1" , "0")| eval B=case(match(source,"source_a.csv$"),"1",match(source,"source_b.csv$"),"0")

PS: like() option suggested by @nickhillscpl, should also work. match() is case sensitive.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

How to use eval with IF? (2024)
Top Articles
Latest Posts
Article information

Author: Delena Feil

Last Updated:

Views: 6439

Rating: 4.4 / 5 (45 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Delena Feil

Birthday: 1998-08-29

Address: 747 Lubowitz Run, Sidmouth, HI 90646-5543

Phone: +99513241752844

Job: Design Supervisor

Hobby: Digital arts, Lacemaking, Air sports, Running, Scouting, Shooting, Puzzles

Introduction: My name is Delena Feil, I am a clean, splendid, calm, fancy, jolly, bright, faithful person who loves writing and wants to share my knowledge and understanding with you.