<?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 Create a table with different fields depending if their values match a condition in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Create-a-table-with-different-fields-depending-if-their-values/m-p/581910#M202704</link>
    <description>&lt;P&gt;I have a raw where each event looks like this (simplified for this exampel):&lt;BR /&gt;&lt;SPAN&gt;{"&lt;/SPAN&gt;&lt;SPAN class=""&gt;time&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt;&lt;SPAN&gt; "&lt;/SPAN&gt;&lt;SPAN class=""&gt;2022-01-20&lt;/SPAN&gt; &lt;SPAN class=""&gt;16:40:02.325216&lt;/SPAN&gt;&lt;SPAN&gt;", "&lt;/SPAN&gt;&lt;SPAN class=""&gt;name&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt;&lt;SPAN&gt; "&lt;/SPAN&gt;&lt;SPAN class=""&gt;name1&lt;/SPAN&gt;&lt;SPAN&gt;", "&lt;/SPAN&gt;&lt;SPAN class=""&gt;deployment&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt;&lt;SPAN&gt; "&lt;/SPAN&gt;&lt;SPAN class=""&gt;found&lt;/SPAN&gt;&lt;SPAN&gt;", "secret&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt;&lt;SPAN&gt; "&lt;/SPAN&gt;&lt;SPAN class=""&gt;correct&lt;/SPAN&gt;&lt;SPAN&gt;"}&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If "deployment": "not_found",&amp;nbsp;&lt;/SPAN&gt;I would like to have a table like:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;time&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;name&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;deployment&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;&lt;SPAN class=""&gt;2022-01-20&lt;/SPAN&gt; &lt;SPAN class=""&gt;16:40:02.325216&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;&lt;SPAN class=""&gt;name1&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;not_found&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;&lt;BR /&gt;If "secret": "incorrect",&amp;nbsp;I would like to have a table like:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="226.766px" height="25px"&gt;time&lt;/TD&gt;&lt;TD width="226.766px" height="25px"&gt;name&lt;/TD&gt;&lt;TD width="226.766px" height="25px"&gt;secret&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="226.766px" height="25px"&gt;&lt;SPAN class=""&gt;2022-01-20&lt;/SPAN&gt; &lt;SPAN class=""&gt;16:40:02.325216&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="226.766px" height="25px"&gt;&lt;SPAN class=""&gt;name1&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="226.766px" height="25px"&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;incorrect&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;Currently, my search looks like this:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;index=index host=host source=source ("not_found" OR "incorrect")
| table time name deployment secret&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;But this means that both fields (deployment and secret) will be shown no matter what their value is.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/59"&gt;@Ayn&lt;/a&gt;&amp;nbsp;Is there a way to have a table which varies its fields depending on a certain condition?&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;Thanks in advance!&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 20 Jan 2022 16:00:46 GMT</pubDate>
    <dc:creator>andres</dc:creator>
    <dc:date>2022-01-20T16:00:46Z</dc:date>
    <item>
      <title>Create a table with different fields depending if their values match a condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-a-table-with-different-fields-depending-if-their-values/m-p/581910#M202704</link>
      <description>&lt;P&gt;I have a raw where each event looks like this (simplified for this exampel):&lt;BR /&gt;&lt;SPAN&gt;{"&lt;/SPAN&gt;&lt;SPAN class=""&gt;time&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt;&lt;SPAN&gt; "&lt;/SPAN&gt;&lt;SPAN class=""&gt;2022-01-20&lt;/SPAN&gt; &lt;SPAN class=""&gt;16:40:02.325216&lt;/SPAN&gt;&lt;SPAN&gt;", "&lt;/SPAN&gt;&lt;SPAN class=""&gt;name&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt;&lt;SPAN&gt; "&lt;/SPAN&gt;&lt;SPAN class=""&gt;name1&lt;/SPAN&gt;&lt;SPAN&gt;", "&lt;/SPAN&gt;&lt;SPAN class=""&gt;deployment&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt;&lt;SPAN&gt; "&lt;/SPAN&gt;&lt;SPAN class=""&gt;found&lt;/SPAN&gt;&lt;SPAN&gt;", "secret&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt;&lt;SPAN&gt; "&lt;/SPAN&gt;&lt;SPAN class=""&gt;correct&lt;/SPAN&gt;&lt;SPAN&gt;"}&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If "deployment": "not_found",&amp;nbsp;&lt;/SPAN&gt;I would like to have a table like:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;time&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;name&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;deployment&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;&lt;SPAN class=""&gt;2022-01-20&lt;/SPAN&gt; &lt;SPAN class=""&gt;16:40:02.325216&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;&lt;SPAN class=""&gt;name1&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;not_found&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;&lt;BR /&gt;If "secret": "incorrect",&amp;nbsp;I would like to have a table like:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="226.766px" height="25px"&gt;time&lt;/TD&gt;&lt;TD width="226.766px" height="25px"&gt;name&lt;/TD&gt;&lt;TD width="226.766px" height="25px"&gt;secret&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="226.766px" height="25px"&gt;&lt;SPAN class=""&gt;2022-01-20&lt;/SPAN&gt; &lt;SPAN class=""&gt;16:40:02.325216&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="226.766px" height="25px"&gt;&lt;SPAN class=""&gt;name1&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="226.766px" height="25px"&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;incorrect&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;Currently, my search looks like this:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;index=index host=host source=source ("not_found" OR "incorrect")
| table time name deployment secret&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;But this means that both fields (deployment and secret) will be shown no matter what their value is.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/59"&gt;@Ayn&lt;/a&gt;&amp;nbsp;Is there a way to have a table which varies its fields depending on a certain condition?&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;Thanks in advance!&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jan 2022 16:00:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-a-table-with-different-fields-depending-if-their-values/m-p/581910#M202704</guid>
      <dc:creator>andres</dc:creator>
      <dc:date>2022-01-20T16:00:46Z</dc:date>
    </item>
    <item>
      <title>Re: Create a table with different fields depending if their values match a condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-a-table-with-different-fields-depending-if-their-values/m-p/581995#M202731</link>
      <description>&lt;P&gt;A table can have only one set of headings.&amp;nbsp; You can combine two columns into one using &lt;FONT face="courier new,courier"&gt;coalesce&lt;/FONT&gt;.&amp;nbsp; For example, this query will create a 3-column table with either deployment or secret in column3.&amp;nbsp; The trick for the reader, however, is to determine which it is.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=index host=host source=source ("not_found" OR "incorrect")
| eval column3 = coalesce(deployment, secret)
| rename column3 as "deployment or secret"
| table time name "deployment or secret"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jan 2022 13:26:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-a-table-with-different-fields-depending-if-their-values/m-p/581995#M202731</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2022-01-21T13:26:04Z</dc:date>
    </item>
    <item>
      <title>Re: Create a table with different fields depending if their values match a condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-a-table-with-different-fields-depending-if-their-values/m-p/582086#M202761</link>
      <description>&lt;P&gt;See if something like this works for you.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=index host=host source=source ("not_found" OR "incorrect")
|  table time name deployment secret
|  eval metric=if(deployment="not found", "deployment", "secret")
|  eval val=if(deployment="not found", "not found", "incorrect") 
|  table time name metric val 
|  eval {metric}=val 
|  fields - metric val&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 21 Jan 2022 19:24:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-a-table-with-different-fields-depending-if-their-values/m-p/582086#M202761</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2022-01-21T19:24:10Z</dc:date>
    </item>
  </channel>
</rss>

