<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Why is my $result.fieldname$ value isnt working? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Why-is-my-result-fieldname-value-isnt-working/m-p/355296#M23170</link>
    <description>&lt;P&gt;The token i set for "$result.sum$" isn't working when i call it in title. Is there something wrong with my code?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;     &amp;lt;search&amp;gt;
                &amp;lt;query&amp;gt;index="ape_idx" sourcetype="ape_csv" "Account Group" != "Infrastructure Services"  
                  | eval week = strptime(Reporting_Week,"%m/%d/%Y")  
                  | sort -week limit=0  | dedup "Project Id" 
                  | fillnull value=NA  | lookup geo_region_new "Dominant Geographic Unit" as "Geographic Unit" outputnew "Geographic Region" 
                  | search "Geographic Region" = "AAPAC" | stats count as "Project Count" by "Geographic Region","Geographic Unit" 
                  | eventstats sum("Project Count") as Sum | fields - "Geographic Region","Geographic Unit", "Project Count" | dedup Sum
               &amp;lt;/query&amp;gt;
                    &amp;lt;done&amp;gt;
                        &amp;lt;set token="aapacCount"&amp;gt;$result.Sum$&amp;lt;/set&amp;gt;
                     &amp;lt;/done&amp;gt;
          &amp;lt;!---end of search for total count of aapac--&amp;gt;
            &amp;lt;title&amp;gt;Total Count: $aapacCount$&amp;lt;/title&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 23 Apr 2018 02:39:08 GMT</pubDate>
    <dc:creator>patricianaguit</dc:creator>
    <dc:date>2018-04-23T02:39:08Z</dc:date>
    <item>
      <title>Why is my $result.fieldname$ value isnt working?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Why-is-my-result-fieldname-value-isnt-working/m-p/355296#M23170</link>
      <description>&lt;P&gt;The token i set for "$result.sum$" isn't working when i call it in title. Is there something wrong with my code?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;     &amp;lt;search&amp;gt;
                &amp;lt;query&amp;gt;index="ape_idx" sourcetype="ape_csv" "Account Group" != "Infrastructure Services"  
                  | eval week = strptime(Reporting_Week,"%m/%d/%Y")  
                  | sort -week limit=0  | dedup "Project Id" 
                  | fillnull value=NA  | lookup geo_region_new "Dominant Geographic Unit" as "Geographic Unit" outputnew "Geographic Region" 
                  | search "Geographic Region" = "AAPAC" | stats count as "Project Count" by "Geographic Region","Geographic Unit" 
                  | eventstats sum("Project Count") as Sum | fields - "Geographic Region","Geographic Unit", "Project Count" | dedup Sum
               &amp;lt;/query&amp;gt;
                    &amp;lt;done&amp;gt;
                        &amp;lt;set token="aapacCount"&amp;gt;$result.Sum$&amp;lt;/set&amp;gt;
                     &amp;lt;/done&amp;gt;
          &amp;lt;!---end of search for total count of aapac--&amp;gt;
            &amp;lt;title&amp;gt;Total Count: $aapacCount$&amp;lt;/title&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Apr 2018 02:39:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Why-is-my-result-fieldname-value-isnt-working/m-p/355296#M23170</guid>
      <dc:creator>patricianaguit</dc:creator>
      <dc:date>2018-04-23T02:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my $result.fieldname$ value isnt working?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Why-is-my-result-fieldname-value-isnt-working/m-p/355297#M23171</link>
      <description>&lt;P&gt;&lt;CODE&gt;&amp;lt;title&amp;gt;&lt;/CODE&gt; isn't valid inside &lt;CODE&gt;&amp;lt;search&amp;gt;&lt;/CODE&gt;, so it needs to be moved out.  This run anywhere example shows what you're trying to accomplish, though:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;title&amp;gt;$aapacCount$&amp;lt;/title&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;| tstats count WHERE index=* OR index=_*&amp;lt;/query&amp;gt;
           &amp;lt;done&amp;gt;
              &amp;lt;set token="aapacCount"&amp;gt;$result.count$&amp;lt;/set&amp;gt;
            &amp;lt;/done&amp;gt;
          &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="count"&amp;gt;20&amp;lt;/option&amp;gt;
        &amp;lt;option name="dataOverlayMode"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="percentagesRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="rowNumbers"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="totalsRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="wrap"&amp;gt;true&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/dashboard&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Apr 2018 03:16:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Why-is-my-result-fieldname-value-isnt-working/m-p/355297#M23171</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2018-04-23T03:16:25Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my $result.fieldname$ value isnt working?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Why-is-my-result-fieldname-value-isnt-working/m-p/355298#M23172</link>
      <description>&lt;P&gt;@patricianaguit have you ensured that your search is returning result/s? Also do you have earliest and latest time tokens passed to the search? It seems to be missing in the sample code. Just to be sure that &lt;CODE&gt;$result.Sum$&lt;/CODE&gt; picks a value even if underlying search returned no results you can try the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;query&amp;gt;
   &amp;lt;yourQueryGoesHere&amp;gt;
&amp;lt;/query&amp;gt;
&amp;lt;earliest&amp;gt;&amp;lt;yourEarliestTimeHere&amp;gt;&amp;lt;/earliest&amp;gt;
&amp;lt;latest&amp;gt;&amp;lt;yourLatestTimeHere&amp;gt;&amp;lt;/latest&amp;gt;
&amp;lt;done&amp;gt;
      &amp;lt;condition match="$job.resultCount$==0"&amp;gt;
            &amp;lt;set token="aapacCount"&amp;gt;0&amp;lt;/set&amp;gt;
      &amp;lt;/condition&amp;gt;
      &amp;lt;condition match="$job.resultCount$==0"&amp;gt;
            &amp;lt;set token="aapacCount"&amp;gt;$result.Sum$&amp;lt;/set&amp;gt;
      &amp;lt;/condition&amp;gt;
&amp;lt;/done&amp;gt;
&amp;lt;row&amp;gt;
        &amp;lt;panel&amp;gt;
               &amp;lt;title&amp;gt;$aapacCount$&amp;lt;/title&amp;gt;
        &amp;lt;/panel&amp;gt;
&amp;lt;/row&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Second reason could be that query is taking too long to run. So you can try &lt;CODE&gt;&amp;lt;progress&amp;gt;&lt;/CODE&gt; event handler instead of done.&lt;/P&gt;

&lt;P&gt;Just a question are you on Splunk 6.5 or Higher?&lt;/P&gt;

&lt;P&gt;Besides the points about the Token, you search query needs some tweaking:&lt;BR /&gt;
1) I dont see a use of &lt;CODE&gt;week&lt;/CODE&gt; field created, hence sort also.&lt;BR /&gt;
2) dedup should be performed right after getting events from the base search.&lt;BR /&gt;
3) stats should be done first then lookup then filter.&lt;BR /&gt;
4) If you need the &lt;CODE&gt;Sum&lt;/CODE&gt; field alone, perform &lt;CODE&gt;stats&lt;/CODE&gt; which will just retain Sum field and not eventstats followed by removal of unwanted fields.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Apr 2018 06:46:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Why-is-my-result-fieldname-value-isnt-working/m-p/355298#M23172</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-04-23T06:46:26Z</dc:date>
    </item>
  </channel>
</rss>

