Dashboards & Visualizations

In a dashboard, how do I set a token using the first value from a sort?

barrowvian
Explorer

The first panel in my dashboard shows the amount of unique users for each software package feature version. The search I uses the DC function with the chart command to return the amount of unique users, list them by feature version, and then sort them;

| chart dc(USER_NAME) as "Unique User" BY FEATURE_VERSION
| sort +"Feature Version"

Once the user clicks on a specific version from panel one, I have a second panel on the dashboard which displays the usernames of the individuals. If the user doesn't click on a feature version in panel one, the second panel remains as "No results found".

What I'd like to do is set a token based on the first value from when the sort is produced. So, if that first value is 111 , then the token would be, by default, set to 111.

I'm not sure how to set a token based on that first sorted value. Any help would be much appreciated. Thank you.

0 Karma
1 Solution

renjith_nair
Legend

@barrowvian,

You can set the token on the search event done or progress for the first panel .

Here is a run anywhere example. As soon as the first panel is done, sourcetype token is set to the first value of the result. This token is then overriden by the clicked value later.

<dashboard>
  <label>First Value Token</label>
  <row>
    <panel>
      <table>
        <search>
          <query>index=_*|chart count by sourcetype|sort +sourcetype</query>
          <earliest>-15m</earliest>
          <latest>now</latest>
          <sampleRatio>1</sampleRatio>
          <!-- Set result.fieldvalue to the token. done can be replaced by progress as well-->
          <done>
            <set token="sourcetype">$result.sourcetype$</set>
          </done>
        </search>
        <option name="count">20</option>
        <option name="dataOverlayMode">none</option>
        <option name="drilldown">cell</option>
        <option name="percentagesRow">false</option>
        <option name="rowNumbers">false</option>
        <option name="totalsRow">false</option>
        <option name="wrap">true</option>
        <!-- Same token is used in drilldown also-->
        <drilldown>
          <set token="sourcetype">$row.sourcetype$</set>
        </drilldown>
      </table>
    </panel>
  </row>
  <row>
    <panel>
      <table>
        <search>
          <query>index=_* sourcetype=$sourcetype$ |stats count by sourcetype</query>
          <earliest>-15m</earliest>
          <latest>now</latest>
        </search>
        <option name="drilldown">none</option>
      </table>
    </panel>
  </row>
</dashboard>
---
What goes around comes around. If it helps, hit it with Karma 🙂

View solution in original post

renjith_nair
Legend

@barrowvian,

You can set the token on the search event done or progress for the first panel .

Here is a run anywhere example. As soon as the first panel is done, sourcetype token is set to the first value of the result. This token is then overriden by the clicked value later.

<dashboard>
  <label>First Value Token</label>
  <row>
    <panel>
      <table>
        <search>
          <query>index=_*|chart count by sourcetype|sort +sourcetype</query>
          <earliest>-15m</earliest>
          <latest>now</latest>
          <sampleRatio>1</sampleRatio>
          <!-- Set result.fieldvalue to the token. done can be replaced by progress as well-->
          <done>
            <set token="sourcetype">$result.sourcetype$</set>
          </done>
        </search>
        <option name="count">20</option>
        <option name="dataOverlayMode">none</option>
        <option name="drilldown">cell</option>
        <option name="percentagesRow">false</option>
        <option name="rowNumbers">false</option>
        <option name="totalsRow">false</option>
        <option name="wrap">true</option>
        <!-- Same token is used in drilldown also-->
        <drilldown>
          <set token="sourcetype">$row.sourcetype$</set>
        </drilldown>
      </table>
    </panel>
  </row>
  <row>
    <panel>
      <table>
        <search>
          <query>index=_* sourcetype=$sourcetype$ |stats count by sourcetype</query>
          <earliest>-15m</earliest>
          <latest>now</latest>
        </search>
        <option name="drilldown">none</option>
      </table>
    </panel>
  </row>
</dashboard>
---
What goes around comes around. If it helps, hit it with Karma 🙂
Get Updates on the Splunk Community!

.conf25 Community Recap

Hello Splunkers, And just like that, .conf25 is in the books! What an incredible few days — full of learning, ...

Splunk App Developers | .conf25 Recap & What’s Next

If you stopped by the Builder Bar at .conf25 this year, thank you! The retro tech beer garden vibes were ...

Congratulations to the 2025-2026 SplunkTrust!

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