<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: What am I doing wrong with this case function??? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/What-am-I-doing-wrong-with-this-case-function/m-p/672797#M230416</link>
    <description>&lt;P&gt;Not downplaying the significance, just trying to assist with troubleshooting with similar issues I have seen in the past.&lt;BR /&gt;&lt;BR /&gt;Good luck&lt;/P&gt;</description>
    <pubDate>Wed, 27 Dec 2023 20:52:12 GMT</pubDate>
    <dc:creator>dtburrows3</dc:creator>
    <dc:date>2023-12-27T20:52:12Z</dc:date>
    <item>
      <title>What am I doing wrong with this case function???</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-am-I-doing-wrong-with-this-case-function/m-p/672773#M230400</link>
      <description>&lt;P&gt;I have tried to use the following eval to pretty up the return of a field but the result is always test.&amp;nbsp; I have tried single and double quotes around the host.domain field but it always just gives test.&amp;nbsp; I keep on looking for a typo or something but I am at a loss&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval dct_domain=case(host.domain=="prd", "Production", host.domain=="uat", "Pre-Production", host.domain=="dev", "Development", true(), "test" )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Pat_0-1703698614853.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28668i94304FFFFC219EB6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Pat_0-1703698614853.png" alt="Pat_0-1703698614853.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TEMPORARY EDIT - So while trying a thing from whats been suggested so far I found that when I click on host.domain in the left side and choose prd it gives me no results despite the fact it clearly lists it in results (which for that type of selection option it has to be in the results).&amp;nbsp; So I brought the search down to just:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;index=dct_foglight_shr "host.domain"=prd&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and no results show.&amp;nbsp; anyway im opening a splunk ticket&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2023 20:24:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-am-I-doing-wrong-with-this-case-function/m-p/672773#M230400</guid>
      <dc:creator>Pat</dc:creator>
      <dc:date>2023-12-27T20:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: What am I doing wrong with this case function???</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-am-I-doing-wrong-with-this-case-function/m-p/672779#M230402</link>
      <description>&lt;P&gt;Try single quotes around the fieldname in the case statement&lt;BR /&gt;&lt;BR /&gt;Splunk can be finicky about fieldnames with certain characters such as ".", "{}"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval dct_domain=case('host.domain'=="prd", "Production", 'host.domain'=="uat", "Pre-Production", 'host.domain'=="dev", "Development", true(), "test" )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dtburrows3_0-1703702509451.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28670i6293F8B24EDA44E5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dtburrows3_0-1703702509451.png" alt="dtburrows3_0-1703702509451.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2023 18:44:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-am-I-doing-wrong-with-this-case-function/m-p/672779#M230402</guid>
      <dc:creator>dtburrows3</dc:creator>
      <dc:date>2023-12-27T18:44:41Z</dc:date>
    </item>
    <item>
      <title>Re: What am I doing wrong with this case function???</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-am-I-doing-wrong-with-this-case-function/m-p/672781#M230403</link>
      <description>&lt;P&gt;Try:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval dct_domain=case(host.domain==prd, "Production", host.domain==uat, "Pre-Production", host.domain==dev, "Development", true(), "test" )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2023 19:00:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-am-I-doing-wrong-with-this-case-function/m-p/672781#M230403</guid>
      <dc:creator>jason_hotchkiss</dc:creator>
      <dc:date>2023-12-27T19:00:43Z</dc:date>
    </item>
    <item>
      <title>Re: What am I doing wrong with this case function???</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-am-I-doing-wrong-with-this-case-function/m-p/672789#M230410</link>
      <description>&lt;P&gt;unfortunately I tried single and double quotes on the fieldname and it does not work.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2023 20:16:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-am-I-doing-wrong-with-this-case-function/m-p/672789#M230410</guid>
      <dc:creator>Pat</dc:creator>
      <dc:date>2023-12-27T20:16:02Z</dc:date>
    </item>
    <item>
      <title>Re: What am I doing wrong with this case function???</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-am-I-doing-wrong-with-this-case-function/m-p/672791#M230412</link>
      <description>&lt;P&gt;Maybe there is a space on the edges of the string?&lt;BR /&gt;&lt;BR /&gt;What do you get when you do this in your eval instead?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval
        dct_domain=case(match('host.domain', "prd"), "Production", match('host.domain', "uat"), "Pre-Production", match('host.domain', "dev"), "Development", true(), "test" )&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 27 Dec 2023 20:30:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-am-I-doing-wrong-with-this-case-function/m-p/672791#M230412</guid>
      <dc:creator>dtburrows3</dc:creator>
      <dc:date>2023-12-27T20:30:24Z</dc:date>
    </item>
    <item>
      <title>Re: What am I doing wrong with this case function???</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-am-I-doing-wrong-with-this-case-function/m-p/672792#M230413</link>
      <description>&lt;P&gt;I updated the question maybe just as you where answering.&amp;nbsp; I found the field was not showing results even when I did a simple search and through the gui chose the value for host.domain.&amp;nbsp; something fishy is going on.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2023 20:32:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-am-I-doing-wrong-with-this-case-function/m-p/672792#M230413</guid>
      <dc:creator>Pat</dc:creator>
      <dc:date>2023-12-27T20:32:54Z</dc:date>
    </item>
    <item>
      <title>Re: What am I doing wrong with this case function???</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-am-I-doing-wrong-with-this-case-function/m-p/672795#M230414</link>
      <description>&lt;P&gt;My last response still holds to test if it in fact whitespace in the string.&lt;BR /&gt;&lt;BR /&gt;As you can see by this screenshot I was able to replicate you issue with trailing whitespace.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dtburrows3_0-1703709482279.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28671iD16F314A8F4B6CF9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dtburrows3_0-1703709482279.png" alt="dtburrows3_0-1703709482279.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But when updating the eval it fixes the output to intended behavior&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dtburrows3_1-1703709538056.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28672i153F62E665333902/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dtburrows3_1-1703709538056.png" alt="dtburrows3_1-1703709538056.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;At the very least this would rule out if whitespace in the string is the issue.&lt;BR /&gt;&lt;BR /&gt;You could also try this on the search bar and see what returns&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=dct_foglight_shr "host.domain"="*prd*"
    | stats count by "host.domain"
    | eval
        dct_domain=case(match('host.domain', "prd"), "Production", match('host.domain', "uat"), "Pre-Production", match('host.domain', "dev"), "Development", true(), "test" )&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2023 20:41:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-am-I-doing-wrong-with-this-case-function/m-p/672795#M230414</guid>
      <dc:creator>dtburrows3</dc:creator>
      <dc:date>2023-12-27T20:41:09Z</dc:date>
    </item>
    <item>
      <title>Re: What am I doing wrong with this case function???</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-am-I-doing-wrong-with-this-case-function/m-p/672796#M230415</link>
      <description>&lt;P&gt;I think you may be missing the significance of it.&amp;nbsp; You see its not responding to the field at all for searching.&amp;nbsp; even when filtering for it using mouse clicks so there is no possibility of errant spaces at that point since splunk itself puts the text in based on mouse selection.&amp;nbsp; There is something very strange going on.&amp;nbsp; I have done filtering on other fields with mouseclicks jut in case and they react fine.&amp;nbsp; Not sure what the issue is with this specific field but its enough of an issue with splunk directly that I just put in a ticket about it.&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2023 20:45:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-am-I-doing-wrong-with-this-case-function/m-p/672796#M230415</guid>
      <dc:creator>Pat</dc:creator>
      <dc:date>2023-12-27T20:45:14Z</dc:date>
    </item>
    <item>
      <title>Re: What am I doing wrong with this case function???</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-am-I-doing-wrong-with-this-case-function/m-p/672797#M230416</link>
      <description>&lt;P&gt;Not downplaying the significance, just trying to assist with troubleshooting with similar issues I have seen in the past.&lt;BR /&gt;&lt;BR /&gt;Good luck&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2023 20:52:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-am-I-doing-wrong-with-this-case-function/m-p/672797#M230416</guid>
      <dc:creator>dtburrows3</dc:creator>
      <dc:date>2023-12-27T20:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: What am I doing wrong with this case function???</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-am-I-doing-wrong-with-this-case-function/m-p/672798#M230417</link>
      <description>&lt;P&gt;yeah sorry.&amp;nbsp; im not accusing you of anything.&amp;nbsp; Its just the problem is showing itself in a much more rigid way.&amp;nbsp;&amp;nbsp;index=dct_foglight_shr "host.domain"=prd is not working and&amp;nbsp;"host.domain"=prd was added completely with mouseclicks so no possibility at all of whitespace being added as splunk itself is adding it in response to mouse clicks.&amp;nbsp; So once I have fixed the issue with the field in general if case is still acting wonky I will attempt your fix advice.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2023 20:57:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-am-I-doing-wrong-with-this-case-function/m-p/672798#M230417</guid>
      <dc:creator>Pat</dc:creator>
      <dc:date>2023-12-27T20:57:30Z</dc:date>
    </item>
    <item>
      <title>Re: What am I doing wrong with this case function???</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-am-I-doing-wrong-with-this-case-function/m-p/672800#M230418</link>
      <description>&lt;P&gt;and oh wow.&amp;nbsp; I owe you a big apology as yes, splunk itself is somehow not putting in whats there even when selected with the mouse.&amp;nbsp; so its still an issue they are looking into and on my side I will be talking to a team about data cleanup but Im going to try your workaround and if it works I will mark it as the fix.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2023 21:37:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-am-I-doing-wrong-with-this-case-function/m-p/672800#M230418</guid>
      <dc:creator>Pat</dc:creator>
      <dc:date>2023-12-27T21:37:00Z</dc:date>
    </item>
    <item>
      <title>Re: What am I doing wrong with this case function???</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-am-I-doing-wrong-with-this-case-function/m-p/672803#M230420</link>
      <description>&lt;P&gt;The issue is with the data quality and there is some sort of errant spacing in it.&amp;nbsp; I still have a ticket open in splunk as clicking the value of a field should properly put in such spacing but this works as a workaround for me for now.&amp;nbsp; Im further going to speak with the team where the data is coming out of to make sure the data is going out properly (actually need to verify in raw before I go there).&amp;nbsp; thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2023 22:14:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-am-I-doing-wrong-with-this-case-function/m-p/672803#M230420</guid>
      <dc:creator>Pat</dc:creator>
      <dc:date>2023-12-27T22:14:42Z</dc:date>
    </item>
  </channel>
</rss>

