Dashboards & Visualizations

I have two conditions that need to be compared to set token value in a second dropdown

handsomehari
Explorer

I have two conditions needs to be compared to set token value in the second dropdown. First condition from dropdown 1 (token="view") and second condition from dropdown 2 ( token="category"). Please tell us if there is any alternative way of doing this.

    <input type="dropdown" token="view">d<label>View</label>
      <choice value="A">A</choice>
      <choice value="B">B</choice>
      <default>A</default>
    </input>
    <input type="dropdown" token="category">
      <label>Category</label>
      <choice value="X">X</choice>
      <choice value="Y">Y</choice>
      <change>
      <!-- Something like below condition i need -->
        <condition value="X">
            <condition match="$view% == 'A'">
                <set token="showX">Test1</set>
            </condition>
            <condition match="$view% == 'B'">
                <set token="showX">Test2</set>
            </condition>
        </condition>
        <condition value="Y">
            <unset token="showX">Test 3</unset>
        </condition>
      </change>
    </input>
0 Karma
1 Solution

niketn
Legend

@handsomehari, try the following to use <eval> tag in Simple XML to set the token value based on condition.
PS: Since your showX token is depended on both Dropdowns, you would also need to created <change> Event Handler for view, dropdown to set and unset showX token similar (but inverse) to the logic in the category dropdown:

  <fieldset submitButton="false">
    <input type="dropdown" token="view" searchWhenChanged="true">
      <label>View</label>
      <choice value="A">A</choice>
      <choice value="B">B</choice>
      <default>A</default>
      <change>
        <condition value="A">
          <eval token="showX">case($category$=="X","Test1",$category$=="Y",$showX$)</eval>
        </condition>
        <condition value="B">
          <eval token="showX">case($category$=="X","Test2",$category$=="Y",$showX$)</eval>
        </condition>
      </change>
    </input>
    <input type="dropdown" token="category" searchWhenChanged="true">
      <label>Category</label>
      <choice value="X">X</choice>
      <choice value="Y">Y</choice>
      <change>
        <condition value="X">
          <eval token="showX">case($view$=="A","Test1",$view$=="B","Test2")</eval>
        </condition>
        <condition value="Y">
          <unset token="showX"></unset>
        </condition>
      </change>
    </input>    
  </fieldset>

PS: The $category$=="Y",$showX$, unsets the showX token as per requirement.
Following HTML Panel can be added to test the tokens:

  <row>
    <panel>
      <html>
        <b>Token Values</b><br/>
        <div>
          view: $view$<br/>
          category: $category$<br/>
          showX: $showX$<br/>
        </div>  
      </html>
    </panel>
  </row>

Please try out and confirm.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

0 Karma

niketn
Legend

@handsomehari, try the following to use <eval> tag in Simple XML to set the token value based on condition.
PS: Since your showX token is depended on both Dropdowns, you would also need to created <change> Event Handler for view, dropdown to set and unset showX token similar (but inverse) to the logic in the category dropdown:

  <fieldset submitButton="false">
    <input type="dropdown" token="view" searchWhenChanged="true">
      <label>View</label>
      <choice value="A">A</choice>
      <choice value="B">B</choice>
      <default>A</default>
      <change>
        <condition value="A">
          <eval token="showX">case($category$=="X","Test1",$category$=="Y",$showX$)</eval>
        </condition>
        <condition value="B">
          <eval token="showX">case($category$=="X","Test2",$category$=="Y",$showX$)</eval>
        </condition>
      </change>
    </input>
    <input type="dropdown" token="category" searchWhenChanged="true">
      <label>Category</label>
      <choice value="X">X</choice>
      <choice value="Y">Y</choice>
      <change>
        <condition value="X">
          <eval token="showX">case($view$=="A","Test1",$view$=="B","Test2")</eval>
        </condition>
        <condition value="Y">
          <unset token="showX"></unset>
        </condition>
      </change>
    </input>    
  </fieldset>

PS: The $category$=="Y",$showX$, unsets the showX token as per requirement.
Following HTML Panel can be added to test the tokens:

  <row>
    <panel>
      <html>
        <b>Token Values</b><br/>
        <div>
          view: $view$<br/>
          category: $category$<br/>
          showX: $showX$<br/>
        </div>  
      </html>
    </panel>
  </row>

Please try out and confirm.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

handsomehari
Explorer

Thanks!! It is working for me..

0 Karma
Get Updates on the Splunk Community!

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...