Dashboards & Visualizations

How can I toggle between results of different drilldowns in the same dashboard?

DataOrg
Builder

Drilldown: I have two rows in table and want to drill down another panel in same dashboards. if i click on row1 drilldown should have to give one results. if i click row2 I want drilldown2 results

i have a table with 2 rows. if i click the row1 i want the results of drilldown1 and same vice versa if i click row2 i want the results of 2nd drill down panel in the same dashboards

0 Karma
1 Solution

niketn
Legend

You can create the following drilldown in your table

    <drilldown>
      <condition field="GROUP">
        <eval token="token1">case($row.GROUP$="abc","true")</eval>
        <eval token="token2">case($row.GROUP$="bbc","true")</eval>
      </condition>
    </drilldown>

PS: Change values abc and bbcas per your actual field values.
Then you can hide two charts using depends with token1 and token2 i.e.

<chart depends="$token1$">

AND

<chart depends="$token2$">
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

niketn
Legend

You can create the following drilldown in your table

    <drilldown>
      <condition field="GROUP">
        <eval token="token1">case($row.GROUP$="abc","true")</eval>
        <eval token="token2">case($row.GROUP$="bbc","true")</eval>
      </condition>
    </drilldown>

PS: Change values abc and bbcas per your actual field values.
Then you can hide two charts using depends with token1 and token2 i.e.

<chart depends="$token1$">

AND

<chart depends="$token2$">
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

DataOrg
Builder

it working fine.
how to unset both token in single button click?

0 Karma

niketn
Legend

If you want to code a button (either Submit or your own Reset button) to unset the token you will have to use Simple XML JavaScript extension.

If you are fine using a checkbox for the same kind of functionality, you can try out the following code:

Hide Charts

   <condition value="unset">
       <unset token="token1"></unset>
       <unset token="token2"></unset>
       <unset token="form.unsetTokens"></unset>
   </condition>

Change event handler of the Checkbox unsetTokens is used to unset the tokens i.e. token1 and token2. The form level token for checkbox itself i.e. form.unsetTokens is unset to reset the check in the checkbox to give it click kind of feel.

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

DataOrg
Builder

below is my HTML for my button. here where i should add above unset token commands

     <panel>
    <html>
                                     <button class="butn6" data-unset-token="sourcetype1"  >show less details</button>

            <search>
                </search>
                        </html>
    </panel>
0 Karma

niketn
Legend

@premranjithj, above example is from SimpleXML using checkbox, which does not require HTML code.

If you want to add HTML button then you would need to use JavaScript Extension to Simple XML. Can you first try out and confirm adding a checkbox with change event containing above condition block to unset the tokens?

<input type="checkbox" token="unsetTokens" searchWhenChanged="true">
   <label></label>
   <choice value="unset">Hide All</choice>
   <change>
       <condition value="unset">
          <unset token="token1"></unset>
          <unset token="token2"></unset>
          <unset token="form.unsetTokens"></unset>
       </condition>
   </change>
</input>

We can take the button with JavaScript as next step.

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

niketn
Legend

@premjinath, I just checked one of my previous answers I have already mentioned how to create a Refresh button using HTML Panel in Splunk Simple XML dashboard.

   <html>
     <button id="refresh" type="button" class="btn">Refresh
     <i class="icon-rotate" style="font-size: 1em;"></i>
     </button>
   </html>

You will need additional JavaScript code in the Dashboard to reset the tokens:

 require([
     "jquery",
     "splunkjs/mvc/simplexml/eventhandler"
     ],
     function(
         $,        
         EventHandler
         ) {
         //jQuery to capture Refresh button click event    
         $('#refresh').on("click", function() {
             //Use EventHandler utiliy to unsetTokens
             EventHandler.unsetToken("token1");
             EventHandler.unsetToken("token2");
         });
     }
 );

Please try out this one as well. You can use SimpleXML with Checkbox option or SimpleXML JS Extension with Refresh button.

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

DataOrg
Builder

@niketnilay . thanks lot. it working

0 Karma

niketn
Legend

@premranjithj, please upvote the comments that have helped since you have already accepted the answer.

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

DataOrg
Builder

@niketnilay
i need another help.
i have 4 buttons and each button have 2 or 3 hidden panels.
so if i click button1 the hidden panels should be shown. if i click button2 other buttons panels show be hidden and only button2 panels have to visible and vice versa for all buttons

pls help how to do?

0 Karma

niketn
Legend

I think the code remains the same however, you set and unset tokens based on which button is being clicked.

You will additionally require "splunkjs/mvc" to use default or submitted token model.

      // mvc.Components.get() function to get all default Tokens
      var defaultTokenModel = mvc.Components.get("default");
      //jQuery to capture Refresh button click event    
      $('#button1').on("click", function() {
          defaultTokenModel.set("button1","true");
          //Use EventHandler utiliy to unset Tokens
          EventHandler.unsetToken("button2");
          EventHandler.unsetToken("button3");
          EventHandler.unsetToken("button4");
      });

Similarly for other buttons.

Refer to Developer documentation: http://dev.splunk.com/view/webframework-developapps/SP-CAAAEW3

PS: The above code is not tested, so please refer to one of my other answers and Splunk Developer portal to understand the concepts: https://answers.splunk.com/answers/566582/how-to-hide-html-in-panel-when-multiple-tokens-are.html#an...
If it does not work let me know. And if it works dont forget to upvote 🙂

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

niketn
Legend

@premranjithj, please confirm if you were able to try the unset code change as suggested. Did it work fine for you?

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

nishantmishra21
Engager

You can set and unset token on the drilldown option. If you have first column with a key to identify a row and specific behavior, use the below syntax to compare the key and set and unset token .Use the same token to show/hide panels in the dashboard.

    <drilldown>
         <condition match="$row.colmnname$== value1"> 
            <set token="token1">true</set>
            <unset token="token2"></unset>
         <condition>
         <condition match="$row.colmnname$== value2"> 
            <set token="token2">true</set>
            <unset token="token1"></unset>
         <condition>
       </drilldown>

If u are facing issue with simple xml, paste the xml here, will and and fix it. Happy splunking 🙂

0 Karma

DataOrg
Builder

@nishantmishra21

NEXT_PAY_PERIOD_NAME GROUP Total
APRW1-FY18 abc $8,768,545.49
APRW1-FY18 bbc $25,252,666.80

this is my table. if i click on the group column with abc. i have to get chart1 and if i click bbc i need to get chart 2 by unset chart1.
pls correct my code

 <panel>
          <title>Test</title>
          <table>
            <search>
              <query>|abc.csv| stats sum(AMOUNT) as Total by NAME,GROUP|sort PERIOD|eval Total=round(Total,2)| fieldformat Total= "$" + tostring(Total, "commas")</query>
                     </search>
            <drilldown>
              <condition match="$row.colmnname$== value1">
                <set token="token1">true</set>
                <unset token="token2"></unset>
              </condition>
              <condition match="$row.colmnname$== value2">
                <set token="token2">true</set>
                <unset token="token1"></unset>
              </condition>
            </drilldown>
          </table>
        </panel>
      </row>
      <row>
        <panel >
          <chart depends="$token1$">
            <search>
              <query>|query|where PAY_GROUP="abc" | stats sum(PAYMENT_AMOUNT) as Total by CODE,PNAME, GROUP|sort- Total|eval Total=round(Total,2)|stats sum by CODE</query>

            </search>
            <option name="charting.chart">pie</option>
          </chart>
        </panel>
    <panel >
          <chart depends="$token2$">
            <search>
              <query>|query|where PAY_GROUP="abc" | stats sum(PAYMENT_AMOUNT) as Total by CODE,PNAME, GROUP|sort- Total|eval Total=round(Total,2)|stats sum by CODE</query>

            </search>
            <option name="charting.chart">pie</option>
          </chart>
        </panel>
    </row>
0 Karma

ab81428
Path Finder

For Each dashboard/panel You can use separate drill down option giving DRILL DOWN report URL.

Panel/dashboard 1
Next Drill down for the same.

  <single>
    <search>
      <query>index=xyz sourcetype=XXX | .....</query>
      <earliest>-24h@h</earliest>
      <latest>now</latest>
      <sampleRatio>1</sampleRatio>
    </search>
    <!-- <title>abc</title> -->
    <drilldown target="0000">
      <link>
        <![CDATA[URL]]>
        <![CDATA[-]]>
        <![CDATA[.. URL Continue]]>
      </link>
    </drilldown>

Above solution I am using for 16 panel dashboard.

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...