<?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 display columns dynamically in the splunk table output? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-columns-dynamically-in-the-splunk-table-output/m-p/411230#M118644</link>
    <description>&lt;P&gt;@sravanb please try the change event of the dropdown to code as many tokens as you want. Since you have provided partial code, I can help with only as much detail I can add.&lt;/P&gt;

&lt;P&gt;Following is the Dropdown code with &lt;CODE&gt;&amp;lt;change&amp;gt;&lt;/CODE&gt; event handler  that sets new token &lt;CODE&gt;tokSelectedField&lt;/CODE&gt; based on the dropdown value selected:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   ....
   ....
   &amp;lt;label&amp;gt;QueueType&amp;lt;/label&amp;gt;
   &amp;lt;choice value="EnterpriseCompanyQueueListener.log"&amp;gt;Merch&amp;lt;/choice&amp;gt;
   &amp;lt;choice value="InventoryOwnerQueueListener.log"&amp;gt;NonMerch&amp;lt;/choice&amp;gt;
   &amp;lt;default&amp;gt;EnterpriseCompanyQueueListener.log&amp;lt;/default&amp;gt;
   &amp;lt;initialValue&amp;gt;EnterpriseCompanyQueueListener.log&amp;lt;/initialValue&amp;gt;
   &amp;lt;change&amp;gt;
       &amp;lt;condition label="Merch"&amp;gt;
           &amp;lt;set token="tokSelectedField"&amp;gt;ENTERPRISE_COMPANY&amp;lt;/set&amp;gt;
       &amp;lt;/condition&amp;gt;
       &amp;lt;condition label="NonMerch"&amp;gt;
           &amp;lt;set token="tokSelectedField"&amp;gt;INVENTORY_OWNER &amp;lt;/set&amp;gt;
       &amp;lt;/condition&amp;gt;
   &amp;lt;/change&amp;gt;
 &amp;lt;/input&amp;gt;
   ....
   ....
   ....
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then use the token &lt;CODE&gt;$tokSelectedField$&lt;/CODE&gt; in the table command in the query. It will have value either &lt;CODE&gt;ENTERPRISE_COMPANY&lt;/CODE&gt; or &lt;CODE&gt;INVENTORY_OWNER&lt;/CODE&gt; based on your dropdown value selected i.e. &lt;CODE&gt;|table _time LogID $tokSelectedField$ VEHICLE_ID ...&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   &amp;lt;search&amp;gt;
       &amp;lt;query&amp;gt;
             ....
             ....
             |table _time LogID $tokSelectedField$ VEHICLE_ID STOREID STOCK_NUMBER STATUS_MESSAGE FAIL_REASON ERROR_MESSAGE IS_CVS_READ_SUCCESS IS_DATAEDGE_READ_SUCCESS IS_DATAEDGE_UPDATE_SUCCESS HTTP_CD CVS_FIELDS CVSVALUES DMS_FIELDS DMSVALUES
             | sort _time desc
        &amp;lt;/query&amp;gt;
         ....
         ....
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please try out and confirm!&lt;/P&gt;</description>
    <pubDate>Mon, 28 May 2018 12:40:29 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2018-05-28T12:40:29Z</dc:date>
    <item>
      <title>How to display columns dynamically in the splunk table output?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-columns-dynamically-in-the-splunk-table-output/m-p/411227#M118641</link>
      <description>&lt;P&gt;My end goal to achieve is, &lt;BR /&gt;
I have a drop down input for the query that renders the data in the table where I have mentioned what columns to specify.&lt;BR /&gt;
Now the scenario is I dont want all the columns to be displayed all the time. I have to display the columns list based on the drop down input or any other conditions.&lt;/P&gt;

&lt;P&gt;Please let me know the best way to do it.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;My Query:&lt;/STRONG&gt;&lt;BR /&gt;
index="*" LogText.Environment=$env$ source=$logFilePath$ LogText.StatusMessage = $status$ $searchField$$searchString$&lt;BR /&gt;
| rename &lt;BR /&gt;
    LogText.LogId as LogID &lt;BR /&gt;
    LogText.VehicleId as VEHICLE_ID &lt;BR /&gt;
    LogText.StoreId as STOREID &lt;BR /&gt;
    LogText.StockNumber as STOCK_NUMBER &lt;BR /&gt;
    LogText.EnterpriseCompany as ENTERPRISE_COMPANY &lt;BR /&gt;
    LogText.InventoryOwner as INVENTORY_OWNER &lt;BR /&gt;
    LogText.EnterPriseCompanyNotEnabled as AUTHORIZED &lt;BR /&gt;
    LogText.StatusMessage as STATUS_MESSAGE &lt;BR /&gt;
    LogText.UpdateFailureReason as FAIL_REASON&lt;BR /&gt;
    LogText.CvsReadSuccessful as IS_CVS_READ_SUCCESS&lt;BR /&gt;
    LogText.DataEdgeReadSuccessful as IS_DATAEDGE_READ_SUCCESS&lt;BR /&gt;
    LogText.DataEdgeUpdateSuccessful as IS_DATAEDGE_UPDATE_SUCCESS&lt;BR /&gt;&lt;BR /&gt;
    LogText.HttpStatusCode as HTTP_CD &lt;BR /&gt;
    LogText.ErrorMessage as ERROR_MESSAGE&lt;BR /&gt;
    LogText.CompareFieldsAuditLog.CompareFields{}.CvsField as CVS_FIELDS &lt;BR /&gt;
    LogText.CompareFieldsAuditLog.CompareFields{}.CvsValue as CVSVALUES &lt;BR /&gt;
    LogText.CompareFieldsAuditLog.CompareFields{}.DmsField as DMS_FIELDS &lt;BR /&gt;
    LogText.CompareFieldsAuditLog.CompareFields{}.DmsValue as DMSVALUES &lt;BR /&gt;
|table &lt;BR /&gt;
    _time LogID ENTERPRISE_COMPANY INVENTORY_OWNER VEHICLE_ID STOREID STOCK_NUMBER STATUS_MESSAGE FAIL_REASON ERROR_MESSAGE IS_CVS_READ_SUCCESS IS_DATAEDGE_READ_SUCCESS IS_DATAEDGE_UPDATE_SUCCESS HTTP_CD CVS_FIELDS CVSVALUES DMS_FIELDS DMSVALUES&lt;BR /&gt;
| sort _time desc &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Added more details:&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Code for drop down:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  &amp;lt;label&amp;gt;QueueType&amp;lt;/label&amp;gt;
  &amp;lt;choice value="EnterpriseCompanyQueueListener.log"&amp;gt;Merch&amp;lt;/choice&amp;gt;
  &amp;lt;choice value="InventoryOwnerQueueListener.log"&amp;gt;NonMerch&amp;lt;/choice&amp;gt;
  &amp;lt;default&amp;gt;EnterpriseCompanyQueueListener.log&amp;lt;/default&amp;gt;
  &amp;lt;initialValue&amp;gt;EnterpriseCompanyQueueListener.log&amp;lt;/initialValue&amp;gt;
&amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;When we select choice 1, then I need below column list:&lt;BR /&gt;
_time LogID ENTERPRISE_COMPANY VEHICLE_ID STOREID STOCK_NUMBER STATUS_MESSAGE FAIL_REASON ERROR_MESSAGE IS_CVS_READ_SUCCESS IS_DATAEDGE_READ_SUCCESS IS_DATAEDGE_UPDATE_SUCCESS HTTP_CD CVS_FIELDS CVSVALUES DMS_FIELDS DMSVALUES&lt;/P&gt;

&lt;P&gt;When we select choice2, then I need to show below list:&lt;BR /&gt;
_time LogID INVENTORY_OWNER VEHICLE_ID STOREID STOCK_NUMBER STATUS_MESSAGE FAIL_REASON ERROR_MESSAGE IS_CVS_READ_SUCCESS IS_DATAEDGE_READ_SUCCESS IS_DATAEDGE_UPDATE_SUCCESS HTTP_CD CVS_FIELDS CVSVALUES DMS_FIELDS DMSVALUES&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:38:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-columns-dynamically-in-the-splunk-table-output/m-p/411227#M118641</guid>
      <dc:creator>sravanb</dc:creator>
      <dc:date>2020-09-29T19:38:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to display columns dynamically in the splunk table output?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-columns-dynamically-in-the-splunk-table-output/m-p/411228#M118642</link>
      <description>&lt;P&gt;@sravanb what is the Dynamic Condition and what are corresponding Dropdown Input. We would be able to assist you based on that detail. Also what is the current Simple XML code for your Dropdown.&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2018 16:27:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-columns-dynamically-in-the-splunk-table-output/m-p/411228#M118642</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-05-25T16:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to display columns dynamically in the splunk table output?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-columns-dynamically-in-the-splunk-table-output/m-p/411229#M118643</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/201110"&gt;@niketn&lt;/a&gt; Below is the simple XML for the drop down:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  &amp;lt;label&amp;gt;QueueType&amp;lt;/label&amp;gt;
  &amp;lt;choice value="LogFIle1.log"&amp;gt;Merch&amp;lt;/choice&amp;gt;
  &amp;lt;choice value="LogFIle2.log"&amp;gt;NonMerch&amp;lt;/choice&amp;gt;
  &amp;lt;default&amp;gt;LogFIle1.log&amp;lt;/default&amp;gt;
  &amp;lt;initialValue&amp;gt;LogFIle1.log&amp;lt;/initialValue&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;When user selects First choice (LogFile1.log), then in the output columns should be&lt;BR /&gt;
_time LogID &lt;STRONG&gt;ENTERPRISE_COMPANY&lt;/STRONG&gt; VEHICLE_ID STOREID STOCK_NUMBER STATUS_MESSAGE FAIL_REASON ERROR_MESSAGE &lt;/P&gt;

&lt;P&gt;else&lt;BR /&gt;
  _time LogID  &lt;STRONG&gt;INVENTORY_OWNER&lt;/STRONG&gt; VEHICLE_ID STOREID STOCK_NUMBER STATUS_MESSAGE FAIL_REASON ERROR_MESSAGE &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:42:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-columns-dynamically-in-the-splunk-table-output/m-p/411229#M118643</guid>
      <dc:creator>sravanb</dc:creator>
      <dc:date>2020-09-29T19:42:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to display columns dynamically in the splunk table output?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-columns-dynamically-in-the-splunk-table-output/m-p/411230#M118644</link>
      <description>&lt;P&gt;@sravanb please try the change event of the dropdown to code as many tokens as you want. Since you have provided partial code, I can help with only as much detail I can add.&lt;/P&gt;

&lt;P&gt;Following is the Dropdown code with &lt;CODE&gt;&amp;lt;change&amp;gt;&lt;/CODE&gt; event handler  that sets new token &lt;CODE&gt;tokSelectedField&lt;/CODE&gt; based on the dropdown value selected:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   ....
   ....
   &amp;lt;label&amp;gt;QueueType&amp;lt;/label&amp;gt;
   &amp;lt;choice value="EnterpriseCompanyQueueListener.log"&amp;gt;Merch&amp;lt;/choice&amp;gt;
   &amp;lt;choice value="InventoryOwnerQueueListener.log"&amp;gt;NonMerch&amp;lt;/choice&amp;gt;
   &amp;lt;default&amp;gt;EnterpriseCompanyQueueListener.log&amp;lt;/default&amp;gt;
   &amp;lt;initialValue&amp;gt;EnterpriseCompanyQueueListener.log&amp;lt;/initialValue&amp;gt;
   &amp;lt;change&amp;gt;
       &amp;lt;condition label="Merch"&amp;gt;
           &amp;lt;set token="tokSelectedField"&amp;gt;ENTERPRISE_COMPANY&amp;lt;/set&amp;gt;
       &amp;lt;/condition&amp;gt;
       &amp;lt;condition label="NonMerch"&amp;gt;
           &amp;lt;set token="tokSelectedField"&amp;gt;INVENTORY_OWNER &amp;lt;/set&amp;gt;
       &amp;lt;/condition&amp;gt;
   &amp;lt;/change&amp;gt;
 &amp;lt;/input&amp;gt;
   ....
   ....
   ....
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then use the token &lt;CODE&gt;$tokSelectedField$&lt;/CODE&gt; in the table command in the query. It will have value either &lt;CODE&gt;ENTERPRISE_COMPANY&lt;/CODE&gt; or &lt;CODE&gt;INVENTORY_OWNER&lt;/CODE&gt; based on your dropdown value selected i.e. &lt;CODE&gt;|table _time LogID $tokSelectedField$ VEHICLE_ID ...&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   &amp;lt;search&amp;gt;
       &amp;lt;query&amp;gt;
             ....
             ....
             |table _time LogID $tokSelectedField$ VEHICLE_ID STOREID STOCK_NUMBER STATUS_MESSAGE FAIL_REASON ERROR_MESSAGE IS_CVS_READ_SUCCESS IS_DATAEDGE_READ_SUCCESS IS_DATAEDGE_UPDATE_SUCCESS HTTP_CD CVS_FIELDS CVSVALUES DMS_FIELDS DMSVALUES
             | sort _time desc
        &amp;lt;/query&amp;gt;
         ....
         ....
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please try out and confirm!&lt;/P&gt;</description>
      <pubDate>Mon, 28 May 2018 12:40:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-columns-dynamically-in-the-splunk-table-output/m-p/411230#M118644</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-05-28T12:40:29Z</dc:date>
    </item>
  </channel>
</rss>

