Dashboards & Visualizations

Why my condition token not working ?

mah
Builder

Hi, 

I want to use condition to set a "show" OR a "hide" panel (if no result) : 

<row depends="$panel_hide$">
<panel id="no_result">
<title>List</title>
<html>
<style>
#clear .dashboard-panel {background: white;}
</style>
<center>
<h2>No result<i class="icon-check icon-no-underline" style="font-size:100%;color:#65a637;"/>
</h2>
</center>
</html>
</panel>
</row>
<row depends="$panel_show$">
<panel>
<title>List</title>
<table>
<search>
<query>index=A sourcetype="B" id=*
| table id name start end
| sort - start</query>
<earliest>-10m</earliest>
<latest>now</latest>
<sampleRatio>1</sampleRatio>
<finalized>
<condition match="$job.resultCount$&gt;0">
<set token="panel_show">true</set>
</condition>
<condition>
<set token="panel_hide"></set>
<unset token="panel_show"></unset>
</condition>
</finalized>
</search>
<option name="count">20</option>
<option name="dataOverlayMode">none</option>
<option name="drilldown">none</option>
<option name="percentagesRow">false</option>
<option name="refresh.display">progressbar</option>
<option name="rowNumbers">false</option>
<option name="totalsRow">false</option>
<option name="wrap">true</option>
</table>
</panel>
</row>

This code not working... It gives me both panel : 

mah_0-1609068634116.png

 

What it is wrong with my code ?

Thanks for help.

Labels (1)
Tags (1)
0 Karma

renjith_nair
Legend

Add unset token for the panel_hide in the first condition

ie.

<finalized>
 <condition match="$job.resultCount$&gt;0">
  <set token="panel_show">true</set>
  <unset token="panel_hide"></unset>
 </condition>
 <condition>
  <set token="panel_hide"></set>
  <unset token="panel_show"></unset>
 </condition>
</finalized>

 

---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma

mah
Builder

That was the solution ! Thank you. 

Is there a way to create a condition which says : if the table command does not return result so display a massage like "The list is empty" without a panel hide like I did ?

 

0 Karma

renjith_nair
Legend

You may user appendpipe

e.g.

|makeresults count=1|eval data="Something"
|appendpipe [|stats count|where count=0|eval data="The list is empty" |fields - count]

Run this search and change the count value to 0 see the difference. Appreciate 👍 if the solution/replies helps

 

---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...