<?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: How to set column with default value if column key not exist? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-column-with-default-value-if-column-key-not-exist/m-p/291023#M87932</link>
    <description>&lt;P&gt;Hi guys &lt;/P&gt;

&lt;P&gt;I added true(), 5 to the end. but it still not showing S0 column with default value 0. &lt;BR /&gt;
In my data. each issue has its severity, so this time means there's no issue in severity S0. &lt;BR /&gt;
but i want have a column S0 with value 0. &lt;BR /&gt;
Please advise. &lt;/P&gt;

&lt;P&gt;Best&lt;BR /&gt;
Xin&lt;/P&gt;</description>
    <pubDate>Fri, 12 May 2017 18:50:02 GMT</pubDate>
    <dc:creator>hakusama1024</dc:creator>
    <dc:date>2017-05-12T18:50:02Z</dc:date>
    <item>
      <title>How to set column with default value if column key not exist?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-column-with-default-value-if-column-key-not-exist/m-p/291020#M87929</link>
      <description>&lt;P&gt;Hi guys&lt;/P&gt;

&lt;P&gt;I'm trying to create a statistic table for the data from jira. Each column has different severity for jira issue. &lt;BR /&gt;
For example severity from S0 to S3, but there is no S0 level issue. So when i use the chart count b _time, severity it doesn't show the column for S0. I'm wondering is there any way to setup default value to 0 so i can see the missing column. &lt;BR /&gt;
Thanks for help. &lt;/P&gt;

&lt;P&gt;the command i use:&lt;BR /&gt;
index = "demo1" severity != null sdlc_phase !="closed"|dedup key| eval _time=strptime(created,"%Y-%m-%dT%H:%M:%S.000+0000")  | bin _time span="1mon" | eval  n_status=lower('severity')  | eval  sort_field=case(n_status=="s0", 1,n_status=="s1", 2,n_status=="s2", 3,n_status=="s3", 4, n_status=="TOTAL", 5 )| chart count by _time, severity |sort  _time desc | fields  - n_status sort_field  | addtotals&lt;/P&gt;

&lt;P&gt;Best&lt;BR /&gt;
Xin&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:03:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-column-with-default-value-if-column-key-not-exist/m-p/291020#M87929</guid>
      <dc:creator>hakusama1024</dc:creator>
      <dc:date>2020-09-29T14:03:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to set column with default value if column key not exist?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-column-with-default-value-if-column-key-not-exist/m-p/291021#M87930</link>
      <description>&lt;P&gt;@hakusama1024, first off is severity value actually "null" in your events or do you actually want to filter out only event which have severity?&lt;/P&gt;

&lt;P&gt;Since you have used case for n_staus you can define the default value as 0 using either 1==1 or true() , following is an example&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval sort_field=case(
                                    n_status=="s0", 1,
                                    n_status=="s1", 2,
                                    n_status=="s2", 3,
                                    n_status=="s3", 4,
                                    n_status=="TOTAL", 5,
                                    true(),0)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Also, if you are already using chart command (or timechart command), you can directly use &lt;CODE&gt;span="1mon"&lt;/CODE&gt;. &lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 18:40:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-column-with-default-value-if-column-key-not-exist/m-p/291021#M87930</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-05-12T18:40:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to set column with default value if column key not exist?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-column-with-default-value-if-column-key-not-exist/m-p/291022#M87931</link>
      <description>&lt;P&gt;Try this&lt;BR /&gt;
| eval sort_field=case(&lt;BR /&gt;
                                     n_status=="s0", "1",&lt;BR /&gt;
                                     n_status=="s1", "2",&lt;BR /&gt;
                                     n_status=="s2", "3",&lt;BR /&gt;
                                     n_status=="s3", "4",&lt;BR /&gt;
                                     n_status=="TOTAL"," 5",&lt;BR /&gt;
                                     true(),"0")&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:03:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-column-with-default-value-if-column-key-not-exist/m-p/291022#M87931</guid>
      <dc:creator>sravankaripe</dc:creator>
      <dc:date>2020-09-29T14:03:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to set column with default value if column key not exist?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-column-with-default-value-if-column-key-not-exist/m-p/291023#M87932</link>
      <description>&lt;P&gt;Hi guys &lt;/P&gt;

&lt;P&gt;I added true(), 5 to the end. but it still not showing S0 column with default value 0. &lt;BR /&gt;
In my data. each issue has its severity, so this time means there's no issue in severity S0. &lt;BR /&gt;
but i want have a column S0 with value 0. &lt;BR /&gt;
Please advise. &lt;/P&gt;

&lt;P&gt;Best&lt;BR /&gt;
Xin&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 18:50:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-column-with-default-value-if-column-key-not-exist/m-p/291023#M87932</guid>
      <dc:creator>hakusama1024</dc:creator>
      <dc:date>2017-05-12T18:50:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to set column with default value if column key not exist?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-column-with-default-value-if-column-key-not-exist/m-p/291024#M87933</link>
      <description>&lt;P&gt;All that you need to do is add this to your existing (almost working) search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| fillnull s0 s1 s2 s3 s4 s5 value=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Whichever columns do not exist will be created and given a value of &lt;CODE&gt;0&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2017 02:11:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-column-with-default-value-if-column-key-not-exist/m-p/291024#M87933</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-09-06T02:11:25Z</dc:date>
    </item>
  </channel>
</rss>

