Dashboards & Visualizations

how should I assign a value on base of condition?

sanjum01
Explorer

Hi Folks,
I have below code from dashbaord source
<set token="ps">$click.value$></set>
|eval ps>if($click.value$="ESB - Canonical - Tibco", <set token="ps2">6</set>) OR
if( $click.value$=="Guiding Care - Tibco",<set token="ps2">21</set>) OR
if($click.value$=="ESB - Raw data - Boomi",<set token="ps2">1</set>) OR
if($click.value$=="ESB - Raw data - Tibco",<set token="ps2">2</set>) OR
if( $click.value$=="HealthShare - Tibco",<set token="ps2">41</set>) OR
if( $click.value$=="ESB - Canonical - Boomi",<set token="ps2">5</set>) OR
if($click.value$=="EDWADS",<set token="ps2">10</set>) OR
if($click.value$=="EDWIDS",<set token="ps2">15</set>) OR
if($click.value$=="Guiding Care - Boomi",<set token="ps2">20</set>)OR
if($click.value$=="Guiding Care - PopHealthServices (PHS)",<set token="ps2">25</set>)OR
if($click.value$=="CareAnalyzer (CA)",<set token="ps2">30</set>)OR
if($click.value$=="HealthShare",<set token="ps2">40</set>)

I am tryin to assign a value to ps2 on base of condition, but it appears it is always assigning last value (40) no matter what ? any help suggestion please?
Thanks.

Labels (3)
0 Karma
1 Solution

skrajkumar_splu
Splunk Employee
Splunk Employee

I guess its the issue with the nested IF statement. Can you please try like below ?

<drilldown>
          <eval token="ps2">if($click.value$="ESB - Canonical - Tibco", "6" , if($click.value$="Guiding Care - Tibco", "21" , if( $click.value$="Guiding Care - Tibco", "21" , if($click.value$="ESB - Raw data - Boomi", "1" , if($click.value$="ESB - Raw data - Boomi", "1" , if($click.value$="ESB - Raw data - Tibco", "2" , if($click.value$="ESB - Raw data - Tibco", "2" , if( $click.value$="HealthShare - Tibco","41", if( $click.value$="HealthShare - Tibco","41" , if( $click.value$="ESB - Canonical - Boomi","5", if( $click.value$="ESB - Canonical - Boomi","5" , if($click.value$="EDWADS", "10" ,if($click.value$="EDWADS", 10 , if($click.value$="EDWIDS", 15 , if($click.value$="EDWIDS", "15" , if($click.value$="Guiding Care - Boomi", "20", if($click.value$="Guiding Care - Boomi", "20" , if($click.value$="Guiding Care - PopHealthServices (PHS)","25" , if($click.value$="Guiding Care - PopHealthServices (PHS)","25" , if($click.value$="CareAnalyzer (CA)", "30" , if($click.value$="CareAnalyzer (CA)", "30" , if($click.value$="HealthShare", "40" , "false"))))))))))))))))))))))</eval>
          <set token="ps1">$click.value$</set>
        </drilldown>

 

Here ps2 token should carry the numeric value. If nested IF statement is little confusing/ troublesome you can also use case(match(......),...)

View solution in original post

0 Karma

skrajkumar_splu
Splunk Employee
Splunk Employee

I guess its the issue with the nested IF statement. Can you please try like below ?

<drilldown>
          <eval token="ps2">if($click.value$="ESB - Canonical - Tibco", "6" , if($click.value$="Guiding Care - Tibco", "21" , if( $click.value$="Guiding Care - Tibco", "21" , if($click.value$="ESB - Raw data - Boomi", "1" , if($click.value$="ESB - Raw data - Boomi", "1" , if($click.value$="ESB - Raw data - Tibco", "2" , if($click.value$="ESB - Raw data - Tibco", "2" , if( $click.value$="HealthShare - Tibco","41", if( $click.value$="HealthShare - Tibco","41" , if( $click.value$="ESB - Canonical - Boomi","5", if( $click.value$="ESB - Canonical - Boomi","5" , if($click.value$="EDWADS", "10" ,if($click.value$="EDWADS", 10 , if($click.value$="EDWIDS", 15 , if($click.value$="EDWIDS", "15" , if($click.value$="Guiding Care - Boomi", "20", if($click.value$="Guiding Care - Boomi", "20" , if($click.value$="Guiding Care - PopHealthServices (PHS)","25" , if($click.value$="Guiding Care - PopHealthServices (PHS)","25" , if($click.value$="CareAnalyzer (CA)", "30" , if($click.value$="CareAnalyzer (CA)", "30" , if($click.value$="HealthShare", "40" , "false"))))))))))))))))))))))</eval>
          <set token="ps1">$click.value$</set>
        </drilldown>

 

Here ps2 token should carry the numeric value. If nested IF statement is little confusing/ troublesome you can also use case(match(......),...)

0 Karma

sanjum01
Explorer

Thank you so much for your prompt response.
The logic you have provided works as expected for me.
Have a good day!

0 Karma

skrajkumar_splu
Splunk Employee
Splunk Employee

Hi Sanjum01

Can you try using a nested IF instead of using a Boolean expression. Something like the below snippet 

<drilldown>
          <eval token="ps2">if($click.value$="ESB - Canonical - Tibco", "6" , if($click.value$="Guiding Care - Tibco", "21" , "false"))</eval>
        </drilldown>
0 Karma

sanjum01
Explorer

@skrajkumar_splu Thank you for your suggestion.
I tried the suggestion you have provided but it did not work. What else I should try so that my token could get numeric value after i click on bar in a bar chart from previous panel?
<set token="ps">$click.value$></set>
|eval token="ps2">if($click.value$="ESB - Canonical - Tibco", "6" , if($click.value$="Guiding Care - Tibco", "21" , "false")) ,
if( $click.value$="Guiding Care - Tibco", "21" , if($click.value$="ESB - Raw data - Boomi", "1" , "false)),
if($click.value$="ESB - Raw data - Boomi", "1" , if($click.value$="ESB - Raw data - Tibco", "2" , "false")),
if($click.value$="ESB - Raw data - Tibco", "2" , if( $click.value$="HealthShare - Tibco","41", "false")) ,
if( $click.value$="HealthShare - Tibco","41" , if( $click.value$="ESB - Canonical - Boomi","5", "false")) ,
if( $click.value$="ESB - Canonical - Boomi","5" , if($click.value$="EDWADS", "10" , "false")) ,
if($click.value$="EDWADS", 10 , if($click.value$="EDWIDS", 15 ,"false")) ,
if($click.value$="EDWIDS", "15" , if($click.value$="Guiding Care - Boomi", "20" , "false")),
if($click.value$="Guiding Care - Boomi", "20" , if($click.value$="Guiding Care - PopHealthServices (PHS)","25" , "false")),
if($click.value$="Guiding Care - PopHealthServices (PHS)","25" , if($click.value$="CareAnalyzer (CA)", "30" , "false"),
if($click.value$="CareAnalyzer (CA)", "30" , if($click.value$="HealthShare", "40" , "false")),
if($click.value$="HealthShare", "40")
</drilldown>


0 Karma
Get Updates on the Splunk Community!

What's New in Splunk Cloud Platform 9.2.2403?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.2.2403! Analysts can ...

Stay Connected: Your Guide to July and August Tech Talks, Office Hours, and Webinars!

Dive into our sizzling summer lineup for July and August Community Office Hours and Tech Talks. Scroll down to ...

Edge Processor Scaling, Energy & Manufacturing Use Cases, and More New Articles on ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...