Dashboards & Visualizations

Change the one label name in the dynamic dropdown without affecting the actual value

anooshac
Communicator

Hi all,

I have a dynamic dropdown which has the values of a search result. I have a condition where i have to change the display name of one label without affecting the actual value. Does anyone has the solution for this?

Thanks in advance.

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
<panel depends="$UnlockAllCharts$">
<input type="dropdown" token="Tok_Unit" searchWhenChanged="true">
<label>Choose Software Unit</label>
<fieldForLabel>unit_label</fieldForLabel>
<fieldForValue>unit</fieldForValue>
<choice value="InitialValue">All</choice>
<default>InitialValue</default>
<initialValue>InitialValue</initialValue>
<showClearButton>false</showClearButton>
<search>
<query>index=abc source="*project.csv" | dedup unit| table unit | eval unit_label=if(unit="not defined","not categorized",unit)</query>
<earliest>0</earliest>
<latest></latest>
</search>
<change>

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

You have two fields available from the dynamic search to use in the dropdown. One is defined by <fieldForLabel> and the other by <fieldForValue>. Change the dynamic search to return appropriate pairs of label and value.

0 Karma

anooshac
Communicator

I have to change only one label name. Rest of the labels should be remained as such. I have a label named  "not defined", in the dashboard i have to show it as "not categorized". But while that option is clicked it should pass value as "not defined" only. Do you have any solution for this?

 

 

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

In your search query

| eval label=if(value="not defined","not categorized",value)
0 Karma

anooshac
Communicator

Thank you.. I tried this but in the dashboard the vale is showing as "not defined" only.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Can you share your dashboard XML?

0 Karma

anooshac
Communicator

<panel depends="$UnlockAllCharts$">
<input type="dropdown" token="Tok_Unit" searchWhenChanged="true">
<label>Choose Software Unit</label>
<fieldForLabel>unit</fieldForLabel>
<fieldForValue>unit</fieldForValue>
<choice value="InitialValue">All</choice>
<default>InitialValue</default>
<initialValue>InitialValue</initialValue>
<showClearButton>false</showClearButton>
<search>
<query>index=abc source="*project.csv" | dedup unit| table unit </query>
<earliest>0</earliest>
<latest></latest>
</search>
<change>

 

Using this code i get the drop down. I have to change only one label name that is "not defined". But the value it passes should remain unchanged. It should only show "not defined" as "not categorized" in the dashboard only.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
<panel depends="$UnlockAllCharts$">
<input type="dropdown" token="Tok_Unit" searchWhenChanged="true">
<label>Choose Software Unit</label>
<fieldForLabel>unit_label</fieldForLabel>
<fieldForValue>unit</fieldForValue>
<choice value="InitialValue">All</choice>
<default>InitialValue</default>
<initialValue>InitialValue</initialValue>
<showClearButton>false</showClearButton>
<search>
<query>index=abc source="*project.csv" | dedup unit| table unit | eval unit_label=if(unit="not defined","not categorized",unit)</query>
<earliest>0</earliest>
<latest></latest>
</search>
<change>
0 Karma

anooshac
Communicator

It worked properly.. Thank you so much for the help!!

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...