<?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 replace columns based on dropdown tokens? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363348#M23704</link>
    <description>&lt;P&gt;Thanks @DalJeanis, it was a typo where I was missing equal sign for comparing.&lt;/P&gt;

&lt;P&gt;We need single quotes for field names, here the token $VEHICLE_NAME$ gives value (TRACTOR/JEEP), so double quotes is appropriate.&lt;/P&gt;</description>
    <pubDate>Tue, 21 Mar 2017 18:02:48 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2017-03-21T18:02:48Z</dc:date>
    <item>
      <title>How to replace columns based on dropdown tokens?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363338#M23694</link>
      <description>&lt;P&gt;Dear All,&lt;/P&gt;

&lt;P&gt;When i select Tractor, i need to get the two columns in below table like      VEHICLE_NAME,UNITS&lt;BR /&gt;
When i select ZEEP, i need to get the two columns in below table like           VEHICLE_NAME,UNITS1&lt;/P&gt;

&lt;P&gt;Please find the code below. Kindly suggest. Thanks in Advance!&lt;/P&gt;

&lt;P&gt;SAMPLE_TEST&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;input type="dropdown" token="VEHICLE_NAME" searchWhenChanged="true"&amp;gt;
  &amp;lt;label&amp;gt;Select Vehicle&amp;lt;/label&amp;gt;
  &amp;lt;choice value="TRACTOR"&amp;gt;TRACTOR&amp;lt;/choice&amp;gt;
  &amp;lt;choice value="ZEEP"&amp;gt;ZEEP&amp;lt;/choice&amp;gt;
  &amp;lt;fieldForLabel&amp;gt;VEHICLE_NAME&amp;lt;/fieldForLabel&amp;gt;
  &amp;lt;fieldForValue&amp;gt;VEHICLE_NAME&amp;lt;/fieldForValue&amp;gt;
  &amp;lt;search&amp;gt;
    &amp;lt;query&amp;gt;index=idx_color | table VEHICLE_NAME | dedup VEHICLE_NAME&amp;lt;/query&amp;gt;
    &amp;lt;earliest&amp;gt;0&amp;lt;/earliest&amp;gt;
    &amp;lt;latest&amp;gt;&amp;lt;/latest&amp;gt;
  &amp;lt;/search&amp;gt;
  &amp;lt;default&amp;gt;TRACTOR&amp;lt;/default&amp;gt;
  &amp;lt;initialValue&amp;gt;TRACTOR&amp;lt;/initialValue&amp;gt;
&amp;lt;/input&amp;gt;


&amp;lt;panel&amp;gt;
  &amp;lt;table&amp;gt;
    &amp;lt;search&amp;gt;
      &amp;lt;query&amp;gt;index=idx_color VEHICLE_NAME=$VEHICLE_NAME$ | eval UNITS1=coalesce(UNITS1,UNITS)| table VEHICLE_NAME , UNITS,UNITS1 |&amp;lt;/query&amp;gt;
      &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
    &amp;lt;/search&amp;gt;
    &amp;lt;option name="count"&amp;gt;20&amp;lt;/option&amp;gt;
    &amp;lt;option name="dataOverlayMode"&amp;gt;none&amp;lt;/option&amp;gt;
    &amp;lt;option name="drilldown"&amp;gt;cell&amp;lt;/option&amp;gt;
    &amp;lt;option name="percentagesRow"&amp;gt;false&amp;lt;/option&amp;gt;
    &amp;lt;option name="rowNumbers"&amp;gt;false&amp;lt;/option&amp;gt;
    &amp;lt;option name="totalsRow"&amp;gt;false&amp;lt;/option&amp;gt;
    &amp;lt;option name="wrap"&amp;gt;true&amp;lt;/option&amp;gt;
  &amp;lt;/table&amp;gt;
&amp;lt;/panel&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:16:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363338#M23694</guid>
      <dc:creator>splunklakshman</dc:creator>
      <dc:date>2020-09-29T13:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace columns based on dropdown tokens?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363339#M23695</link>
      <description>&lt;P&gt;Will there be always only 2 options in  your dropdown, JEEP and TRACTOR?&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2017 16:34:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363339#M23695</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-03-21T16:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace columns based on dropdown tokens?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363340#M23696</link>
      <description>&lt;P&gt;Jeep  and Tractor only  in this scenario . Pls help.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2017 16:37:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363340#M23696</guid>
      <dc:creator>splunklakshman</dc:creator>
      <dc:date>2017-03-21T16:37:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace columns based on dropdown tokens?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363341#M23697</link>
      <description>&lt;P&gt;Change your panel search like this&lt;BR /&gt;
&lt;STRONG&gt;Updated&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;query&amp;gt;index=idx_color VEHICLE_NAME=$VEHICLE_NAME$ | eval UNITS1=coalesce(UNITS1,UNITS)| table VEHICLE_NAME , [|gentimes start=-1 | eval query=if("$VEHICLE_NAME$"="TRACTOR","UNITS","UNITS1") | table query | format "" "" "" "" "" ""]&amp;lt;/query&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Mar 2017 16:41:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363341#M23697</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-03-21T16:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace columns based on dropdown tokens?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363342#M23698</link>
      <description>&lt;P&gt;Error in 'eval' command: The arguments to the 'if' function are invalid.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2017 16:45:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363342#M23698</guid>
      <dc:creator>splunklakshman</dc:creator>
      <dc:date>2017-03-21T16:45:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace columns based on dropdown tokens?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363343#M23699</link>
      <description>&lt;P&gt;should that be &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval query=if("$VEHICLE_NAME$"="TRACTOR","UNITS","UNITS1") 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval query=if('$VEHICLE_NAME$'="TRACTOR","UNITS","UNITS1")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I can never remember when single-quotes are required... but this is itching like it might be the case...&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2017 17:29:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363343#M23699</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-03-21T17:29:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace columns based on dropdown tokens?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363344#M23700</link>
      <description>&lt;P&gt;If you want to use field name as UNITS when VEHICLE_NAME is TRACTOR and fieldname as UNITS1 when the VEHICLE_NAME is ZEEP and both UNITS and UNITS1 are existing fields available in your indexed data, you can try the following (&lt;STRONG&gt;Dropdown's change event handler is coded using eval to set token for dynamic field name&lt;/STRONG&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;input type="dropdown" token="VEHICLE_NAME" searchWhenChanged="true"&amp;gt;
   &amp;lt;label&amp;gt;Select Vehicle&amp;lt;/label&amp;gt;
   &amp;lt;choice value="TRACTOR"&amp;gt;TRACTOR&amp;lt;/choice&amp;gt;
   &amp;lt;choice value="ZEEP"&amp;gt;ZEEP&amp;lt;/choice&amp;gt;
   &amp;lt;fieldForLabel&amp;gt;VEHICLE_NAME&amp;lt;/fieldForLabel&amp;gt;
   &amp;lt;fieldForValue&amp;gt;VEHICLE_NAME&amp;lt;/fieldForValue&amp;gt;
   &amp;lt;search&amp;gt;
     &amp;lt;query&amp;gt;index=idx_color | table VEHICLE_NAME | dedup VEHICLE_NAME&amp;lt;/query&amp;gt;
     &amp;lt;earliest&amp;gt;0&amp;lt;/earliest&amp;gt;
     &amp;lt;latest&amp;gt;&amp;lt;/latest&amp;gt;
   &amp;lt;/search&amp;gt;
   &amp;lt;default&amp;gt;TRACTOR&amp;lt;/default&amp;gt;
   &amp;lt;initialValue&amp;gt;TRACTOR&amp;lt;/initialValue&amp;gt;
   &amp;lt;change&amp;gt;
       &amp;lt;eval token="tok_fieldName"&amp;gt;case($value$==&amp;amp;quot;TRACTOR&amp;amp;quot;,&amp;amp;quot;UNITS&amp;amp;quot;,1==1,&amp;amp;quot;UNITS1&amp;amp;quot;)&amp;lt;/eval&amp;gt;
   &amp;lt;/change&amp;gt;
 &amp;lt;/input&amp;gt;

 &amp;lt;panel&amp;gt;
   &amp;lt;table&amp;gt;
     &amp;lt;search&amp;gt;
       &amp;lt;query&amp;gt;index=idx_color VEHICLE_NAME=$VEHICLE_NAME$ | table VEHICLE_NAME , $tok_fieldName$ |&amp;lt;/query&amp;gt;
       &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
     &amp;lt;/search&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:17:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363344#M23700</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-09-29T13:17:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace columns based on dropdown tokens?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363345#M23701</link>
      <description>&lt;P&gt;Thanks for your help Niketnilay, i have applied the changes, the logic is working fine but when i select Jeep, the UNITS1 value 10 is not coming. Can you please help.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2017 17:47:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363345#M23701</guid>
      <dc:creator>splunklakshman</dc:creator>
      <dc:date>2017-03-21T17:47:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace columns based on dropdown tokens?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363346#M23702</link>
      <description>&lt;P&gt;Sorry the UNITS Value 20 is not coming. Can you please help.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2017 17:49:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363346#M23702</guid>
      <dc:creator>splunklakshman</dc:creator>
      <dc:date>2017-03-21T17:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace columns based on dropdown tokens?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363347#M23703</link>
      <description>&lt;P&gt;Typo error for UNITS1 , value 20 is not displaying in the row. kindly help.&lt;/P&gt;

&lt;P&gt;WHILE SELECT ZEEP FROM DROPDOWN, THE RESULT IS AS BELOW.&lt;/P&gt;

&lt;P&gt;VEHICLE_NAME      UNITS1&lt;BR /&gt;
ZEEP                       &lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2017 18:01:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363347#M23703</guid>
      <dc:creator>splunklakshman</dc:creator>
      <dc:date>2017-03-21T18:01:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace columns based on dropdown tokens?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363348#M23704</link>
      <description>&lt;P&gt;Thanks @DalJeanis, it was a typo where I was missing equal sign for comparing.&lt;/P&gt;

&lt;P&gt;We need single quotes for field names, here the token $VEHICLE_NAME$ gives value (TRACTOR/JEEP), so double quotes is appropriate.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2017 18:02:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363348#M23704</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-03-21T18:02:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace columns based on dropdown tokens?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363349#M23705</link>
      <description>&lt;P&gt;...pulls out stubby pencil and writes down "token names are not field names..."&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2017 20:20:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363349#M23705</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-03-21T20:20:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace columns based on dropdown tokens?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363350#M23706</link>
      <description>&lt;P&gt;Dear Somesoni and DalJeanis,&lt;/P&gt;

&lt;P&gt;Thanks for the solution, it works as expected.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2017 01:37:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363350#M23706</guid>
      <dc:creator>splunklakshman</dc:creator>
      <dc:date>2017-03-22T01:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace columns based on dropdown tokens?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363351#M23707</link>
      <description>&lt;P&gt;@splunklakshman... Please accept @somesoni2 ' s answer and also upvote @DalJeanis comment, since that is the complete solution for your issue.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2017 02:28:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363351#M23707</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-03-22T02:28:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace columns based on dropdown tokens?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363352#M23708</link>
      <description>&lt;P&gt;@splunklakshman I am not sure what is not working the logic will use field name as UNITS when TRACTOR is selected and UNITS1 when anything else is selected (i.e. for others case is 1==1). Following is simplified version of the same as eval expression to set token will allow double quotes to be used within Simple XML.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;eval token="tok_fieldName"&amp;gt;case($value$=="TRACTOR","UNITS",1==1,"UNITS1")&amp;lt;/eval&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;May be the search query will work if I use original one with coalesce command that you had used. However, I fail to see why you would use coalesce, if you are bothered only for specific column for specific VEHICLE_NAME. Following is the query I think you need:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;query&amp;gt;index=idx_color VEHICLE_NAME=$VEHICLE_NAME$ | eval UNITS1=coalesce(UNITS1,UNITS) | table VEHICLE_NAME , $tok_fieldName$ |&amp;lt;/query&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Mar 2017 02:41:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363352#M23708</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-03-22T02:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace columns based on dropdown tokens?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363353#M23709</link>
      <description>&lt;P&gt;I have added comment to my answer. I did not think you required coalesce command since field names UNITS and UNITS1 were related with TRACTOR and ZEEP respectively.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2017 02:42:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363353#M23709</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-03-22T02:42:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace columns based on dropdown tokens?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363354#M23710</link>
      <description>&lt;P&gt;converted somesoni's answer/comment to an answer so that op CAN accept it.  &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2017 03:37:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-columns-based-on-dropdown-tokens/m-p/363354#M23710</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-03-22T03:37:27Z</dc:date>
    </item>
  </channel>
</rss>

