<?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: Splunk case statement to count values based on field name in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Splunk-case-statement-to-count-values-based-on-field-name/m-p/426389#M169131</link>
    <description>&lt;P&gt;Does every event have those 3 fields? A case statement applies the first matching case and never looks at the rest.&lt;/P&gt;

&lt;P&gt;Can't you simply do a distinct count on those fields (maybe I'm misunderstanding your end goal here though...)?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="test" source="app*.csv"
| eval APPLICATION=case(source="app2.csv","APP2",source="app1","APP1") 
| stats dc(CUSTOMER_ID) dc(ACCOUNT_ID) dc(SUBSCRIPTION_ID) by APPLICATION
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 01 Jun 2018 12:33:12 GMT</pubDate>
    <dc:creator>FrankVl</dc:creator>
    <dc:date>2018-06-01T12:33:12Z</dc:date>
    <item>
      <title>Splunk case statement to count values based on field name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-case-statement-to-count-values-based-on-field-name/m-p/426388#M169130</link>
      <description>&lt;P&gt;Hi team,&lt;BR /&gt;
there are three fields in source "app1.csv" (CUST_ID,ACCT_ID,SUBSCRIP_ID). There is no other field in this table to differentiate these fields.&lt;BR /&gt;
I want to showcase count of each ID field separately. &lt;/P&gt;

&lt;P&gt;index="test" | eval SCHEDULED_DELETIONS=case(&lt;BR /&gt;
source="app1.csv" AND ACTION="SCHEDULED" AND isnotnull(CUST_ID),"CUSTOMER_ID",&lt;BR /&gt;
source="app1.csv" AND ACTION="SCHEDULED" AND isnotnull(ACCT_ID),"ACCOUNT_ID",&lt;BR /&gt;
source="app1.csv" AND ACTION="SCHEDULED" AND isnotnull(SUBSCRIP_ID),"SUBSCRIPTION_ID"&lt;BR /&gt;
source="app2.csv" AND ACTION="TO_DELETE","SUBSCRIPTION_ID",&lt;BR /&gt;
source="app3.csv" AND APP_UNUMBER="U-500","ACCOUNT_ID",&lt;BR /&gt;
source="app4.csv" AND STATUS="N","CUSTOMER_ID",) &lt;/P&gt;

&lt;P&gt;| eval APPLICATION=case(source="app2.csv","APP2",source="app1","APP1") &lt;BR /&gt;
| chart count over APPLICATION BY SCHEDULED_DELETIONS usenull=f&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Issue&lt;/STRONG&gt;: When I do chart, the APP1 shows only CUSTOMER_ID count and ignores ACCOUNT_ID and SUBSCRIPTION_ID count. Also I doubt that isnotnull() is of any is here.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:45:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-case-statement-to-count-values-based-on-field-name/m-p/426388#M169130</guid>
      <dc:creator>anantdeshpande</dc:creator>
      <dc:date>2020-09-29T19:45:11Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk case statement to count values based on field name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-case-statement-to-count-values-based-on-field-name/m-p/426389#M169131</link>
      <description>&lt;P&gt;Does every event have those 3 fields? A case statement applies the first matching case and never looks at the rest.&lt;/P&gt;

&lt;P&gt;Can't you simply do a distinct count on those fields (maybe I'm misunderstanding your end goal here though...)?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="test" source="app*.csv"
| eval APPLICATION=case(source="app2.csv","APP2",source="app1","APP1") 
| stats dc(CUSTOMER_ID) dc(ACCOUNT_ID) dc(SUBSCRIPTION_ID) by APPLICATION
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Jun 2018 12:33:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-case-statement-to-count-values-based-on-field-name/m-p/426389#M169131</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2018-06-01T12:33:12Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk case statement to count values based on field name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-case-statement-to-count-values-based-on-field-name/m-p/426390#M169132</link>
      <description>&lt;P&gt;Hi Frank,&lt;BR /&gt;
Yes. In app1.csv, every event has three fields. As one customer can have multiple accounts, values may be duplicate.&lt;/P&gt;

&lt;P&gt;Is there any alternate solution for "A case statement applies the first matching case and never looks at the rest."???&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jun 2018 13:17:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-case-statement-to-count-values-based-on-field-name/m-p/426390#M169132</guid>
      <dc:creator>anantdeshpande</dc:creator>
      <dc:date>2018-06-01T13:17:08Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk case statement to count values based on field name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-case-statement-to-count-values-based-on-field-name/m-p/426391#M169133</link>
      <description>&lt;P&gt;That depends on what you want to achieve, which is still a bit unclear to me. My suggestion to do a &lt;CODE&gt;stats dc()&lt;/CODE&gt; might be an alternative, but it may not be the calculation you're after.&lt;/P&gt;

&lt;P&gt;Can you perhaps post some sample data + mockup of the expected outcome? That might clarify a bit more what you are actually trying to calculate.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jun 2018 13:41:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-case-statement-to-count-values-based-on-field-name/m-p/426391#M169133</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2018-06-01T13:41:35Z</dc:date>
    </item>
  </channel>
</rss>

