<?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 Re: Lowest single value from multiple fields in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Lowest-single-value-from-multiple-fields/m-p/308591#M19704</link>
    <description>&lt;P&gt;Thank you! I tried this, but the result was still 5. Want to clarify that I need to evaluate only for the latest event.  Did not know that foreach was possible, will check that out.&lt;/P&gt;</description>
    <pubDate>Tue, 29 Aug 2017 13:37:56 GMT</pubDate>
    <dc:creator>epacke</dc:creator>
    <dc:date>2017-08-29T13:37:56Z</dc:date>
    <item>
      <title>Lowest single value from multiple fields</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Lowest-single-value-from-multiple-fields/m-p/308589#M19702</link>
      <description>&lt;P&gt;Dear experts!&lt;BR /&gt;
I have a sourcetype that contains fields like this:&lt;BR /&gt;
domain_field1=5&lt;BR /&gt;
domain_field2=5&lt;BR /&gt;
domain_field3=4&lt;BR /&gt;
domain_field4=3&lt;/P&gt;

&lt;P&gt;And I want to display the lowest number available. To make it more complicated, the number of fields can differ, but they will always be prefixed with "domain_"&lt;/P&gt;

&lt;P&gt;So in the example above the value for the search would be "3".&lt;/P&gt;

&lt;P&gt;Is this possible?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:33:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Lowest-single-value-from-multiple-fields/m-p/308589#M19702</guid>
      <dc:creator>epacke</dc:creator>
      <dc:date>2020-09-29T15:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: Lowest single value from multiple fields</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Lowest-single-value-from-multiple-fields/m-p/308590#M19703</link>
      <description>&lt;P&gt;try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...|foreach domain_* [|eval domain_all=min('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;the foreach statement will grab any field beginning with domain_ and eval the minimum value for all fields. &lt;A href="https://docs.splunk.com/Documentation/SplunkCloud/6.6.1/SearchReference/Foreach"&gt;https://docs.splunk.com/Documentation/SplunkCloud/6.6.1/SearchReference/Foreach&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2017 13:13:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Lowest-single-value-from-multiple-fields/m-p/308590#M19703</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-08-29T13:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: Lowest single value from multiple fields</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Lowest-single-value-from-multiple-fields/m-p/308591#M19704</link>
      <description>&lt;P&gt;Thank you! I tried this, but the result was still 5. Want to clarify that I need to evaluate only for the latest event.  Did not know that foreach was possible, will check that out.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2017 13:37:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Lowest-single-value-from-multiple-fields/m-p/308591#M19704</guid>
      <dc:creator>epacke</dc:creator>
      <dc:date>2017-08-29T13:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: Lowest single value from multiple fields</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Lowest-single-value-from-multiple-fields/m-p/308592#M19705</link>
      <description>&lt;P&gt;I tried this one:&lt;/P&gt;

&lt;P&gt;... | foreach domain_* [|eval laggingdomains=laggingdomains + (5 - '&amp;lt;&amp;gt;')] | table laggingdomains&lt;/P&gt;

&lt;P&gt;That should give me the amount of domains missing (every count below 5 is one missing domain).&lt;/P&gt;

&lt;P&gt;However, the table only contains NULL events. Any idea what I'm doing wrong?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2017 13:54:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Lowest-single-value-from-multiple-fields/m-p/308592#M19705</guid>
      <dc:creator>epacke</dc:creator>
      <dc:date>2017-08-29T13:54:42Z</dc:date>
    </item>
    <item>
      <title>Re: Lowest single value from multiple fields</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Lowest-single-value-from-multiple-fields/m-p/308593#M19706</link>
      <description>&lt;P&gt;Need to declare the field first first:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval laggingdomains=0 | foreach domain_* [|eval laggingdomains=laggingdomains + (5 - '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')] | table laggingdomains
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Aug 2017 14:02:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Lowest-single-value-from-multiple-fields/m-p/308593#M19706</guid>
      <dc:creator>epacke</dc:creator>
      <dc:date>2017-08-29T14:02:07Z</dc:date>
    </item>
    <item>
      <title>Re: Lowest single value from multiple fields</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Lowest-single-value-from-multiple-fields/m-p/308594#M19707</link>
      <description>&lt;P&gt;Thank you for your help. It was invaluable. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2017 14:03:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Lowest-single-value-from-multiple-fields/m-p/308594#M19707</guid>
      <dc:creator>epacke</dc:creator>
      <dc:date>2017-08-29T14:03:01Z</dc:date>
    </item>
    <item>
      <title>Re: Lowest single value from multiple fields</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Lowest-single-value-from-multiple-fields/m-p/308595#M19708</link>
      <description>&lt;P&gt;when i ran this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults | eval domain_field1=5| eval domain_field2=5| eval domain_field3=4| eval domain_field4=3|foreach domain_* [|eval domain_all=min('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;domain_all came back with 3. &lt;BR /&gt;
can i see the query before you run the foreach command?  are you doing a &lt;CODE&gt;|stats latest(domain_*) as domain_*&lt;/CODE&gt; first since you only want the most recent results?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:33:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Lowest-single-value-from-multiple-fields/m-p/308595#M19708</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2020-09-29T15:33:27Z</dc:date>
    </item>
    <item>
      <title>Re: Lowest single value from multiple fields</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Lowest-single-value-from-multiple-fields/m-p/308596#M19709</link>
      <description>&lt;P&gt;Here's the final query that I used:&lt;/P&gt;

&lt;P&gt;| eval laggingdomains=0 | foreach domain_* [|eval laggingdomains=laggingdomains + (5 - '&amp;lt;&amp;gt;')] | sort -_time | table laggingdomains | head 1&lt;/P&gt;

&lt;P&gt;Each domain that is lagging behind will increment the counter by 1.&lt;/P&gt;

&lt;P&gt;/Patrik&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:33:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Lowest-single-value-from-multiple-fields/m-p/308596#M19709</guid>
      <dc:creator>epacke</dc:creator>
      <dc:date>2020-09-29T15:33:29Z</dc:date>
    </item>
    <item>
      <title>Re: Lowest single value from multiple fields</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Lowest-single-value-from-multiple-fields/m-p/555113#M38589</link>
      <description>&lt;P&gt;Actually,&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/185679"&gt;@cmerriman&lt;/a&gt;'s&amp;nbsp;&lt;SPAN&gt;solution will not work as expected.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;When I tried putting other values in the domain fields,&amp;nbsp;domain_all&amp;nbsp;gets the last value foreach&amp;nbsp;sees, which just happens to be&amp;nbsp;domain_field4 in cmerriam's example.&lt;BR /&gt;&lt;BR /&gt;After doing a bit more digging, I managed to find a solution that in fact does return the minimal value no matter the field names' order.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval domain_field1=5
| eval domain_field2=3
| eval domain_field3=2
| eval domain_field4=6
| eval domain_all=now()+(365*24*60*60)
| foreach domain_* 
    [| eval domain_all=min(domain_all,'&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works like a classic "find the minimal value in a list" loop by always giving&amp;nbsp;domain_all&amp;nbsp;the smallest seen value.&lt;BR /&gt;In my opinion this is a better answer than the accepted answer, since you don't always know what the biggest value could be&lt;/P&gt;&lt;P&gt;Either way, I got the idea from&amp;nbsp;&lt;SPAN&gt;epacke's accepted answer, so thanks for that &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jun 2021 15:13:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Lowest-single-value-from-multiple-fields/m-p/555113#M38589</guid>
      <dc:creator>black_bagel</dc:creator>
      <dc:date>2021-06-09T15:13:09Z</dc:date>
    </item>
    <item>
      <title>Re: Lowest single value from multiple fields</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Lowest-single-value-from-multiple-fields/m-p/555119#M38590</link>
      <description>&lt;P&gt;That's a good catch&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/235250"&gt;@black_bagel&lt;/a&gt;&amp;nbsp;, but you don't have to eval domain_all before you do the foreach statement, you could just have&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;|makeresults | eval domain_field1=1| eval domain_field2=5| eval domain_field3=4| eval domain_field4=6|foreach domain_* [|eval domain_all=min(domain_all,'&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')]&lt;/LI-CODE&gt;&lt;P&gt;and that will still produce 1 for domain_all.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jun 2021 15:47:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Lowest-single-value-from-multiple-fields/m-p/555119#M38590</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2021-06-09T15:47:22Z</dc:date>
    </item>
  </channel>
</rss>

