Dashboards & Visualizations

How to use tokens in dashboard panel labels with checkboxes?

aferone
Builder

I understand that there is a bug in using some tokens with checkboxes and the condition tags.

I want to use the value of a token that I am using for a dashboard panel label. Here is the code for the checkbox selection:

<input type="checkbox" token="YearsAx" searchWhenChanged="true">
  <label>Select Years</label>
  <choice value="2017">2017</choice>
  <choice value="2018">2018</choice>
  <delimiter> OR </delimiter>
  <prefix>(</prefix>
  <suffix>)</suffix>
  <valuePrefix>Year="</valuePrefix>
  <valueSuffix>"</valueSuffix>
  <change>
    <condition value="2017">
      <set token="date_label">2017</set>
    </condition>
    <condition value="2018">
      <set token="date_label">2018</set>
    </condition>
  </change>
</input>

However, when I use $YearsAx$ for the dashboard panel label, I get this (a few examples):

Summary By Program (In Plan) (Year="2018" OR Year="2017")
Summary By Program (In Plan) (Year="2017")
Summary By Program (In Plan) (Year="2018")

The condition tags would normally be used to set a different token, but they don't seem to work with checkboxes.

How can I work around it so that I can show a proper dashboard label? Something like this:

 Summary By Program (In Plan) 2017 and 2018
 Summary By Program (In Plan) 2017
 Summary By Program (In Plan) 2018

Thank you!

0 Karma

sbbadri
Motivator

@aferone

Please try this

<form>
  <label>testCheckbox</label>
  <fieldset submitButton="false" autoRun="true">
    <input type="checkbox" token="YearsAx" searchWhenChanged="true">
      <label>Select Years</label>
      <choice value="2017">2017</choice>
      <choice value="2018">2018</choice>
      <delimiter> and </delimiter>
    </input>
  </fieldset>
  <row>
    <panel>
      <title>Summary By Program (In Plan) $YearsAx$</title>
      <event>
        <search>
          <query>index=_internal sourcetype=splunkd | head 1</query>
          <earliest>-15m</earliest>
          <latest>now</latest>
        </search>
      </event>
    </panel>
  </row>
</form>
0 Karma

aferone
Builder

This is what I am using now, however by using $YearsAx$, my label literally says "Years = 2017". Then if both 2017 and 2018 are selected, I get "Years = 2017 OR Years = 2018". Not ideal.

0 Karma

cmerriman
Super Champion

your using the $YearAx$ token in the label, which has (Year="2017......) defined.

try something like this:

...
<change>
     <condition>
       <set token="date_label">$value$</set>
     </condition>
   </change>
...

and use $date_label$ in the panel.

0 Karma

aferone
Builder

Right. In my example above, I am using the condition tags. I forgot to mention that I first used the $date_label$ token, but it doesn't work. I believe that is where the bug is with using checkboxes. Radio buttons do work, however.

0 Karma
Get Updates on the Splunk Community!

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 ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...