<?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: Union of two queries in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-get-union-of-two-in-one-query-and-extract-even-duplicate/m-p/593396#M48657</link>
    <description>&lt;P&gt;There could be a more practical way like re-using results from a saved job, but assuming that you really really want to do it in one search, you have to simply prepare your results, sort, count and filter.&lt;/P&gt;&lt;PRE&gt;&amp;lt;your base earch up to:&amp;gt;&lt;BR /&gt;| table tenant pass_percent total_request&lt;BR /&gt;| sort - pass_percent&lt;BR /&gt;| streamstats count as passorder&lt;BR /&gt;| sort -&amp;nbsp; total_request&lt;BR /&gt;| streamstats count as totalreqorder&lt;BR /&gt;| where passorder&amp;lt;=3 AND totalreqorder &amp;lt;=10&lt;/PRE&gt;&lt;P&gt;Now you have only those results that are in either top 3 of pass_percent or top 10 of total_request.&lt;/P&gt;&lt;P&gt;The only downside is that if a results meets both those conditions it's listed only once. If you want it twice, you'd need to duplicate those rows. Something like that:&lt;/P&gt;&lt;PRE&gt;| eval splitter=mvappend(if passorder&amp;lt;=3,"split",null(),if totalreqorder&amp;lt;=10,"split",null())&lt;BR /&gt;| mvexpand splitter&lt;/PRE&gt;&lt;P&gt;I understand you can remove the extra fields on your own &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 12 Apr 2022 06:15:56 GMT</pubDate>
    <dc:creator>PickleRick</dc:creator>
    <dc:date>2022-04-12T06:15:56Z</dc:date>
    <item>
      <title>How to get union of two in one query and extract even duplicate result?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-get-union-of-two-in-one-query-and-extract-even-duplicate/m-p/593392#M48656</link>
      <description>&lt;P&gt;I have two queries&lt;/P&gt;
&lt;P&gt;index="gtw-ilb" /v1/platform/change_indicators host="*dev01*"| search sourcetype="nginx:plus:access" |eval env = mvindex(split(host, "-"), 1)&lt;BR /&gt;| convert num(status) as response_code&lt;BR /&gt;| eval env = mvindex(split(host, "-"), 1) |eval tenant=split(access_request, "tenantId=")| eval tenant=mvindex(tenant, 1) | eval tenant=split(tenant, "&amp;amp;#38;") | eval tenant=mvindex(tenant, 0)&lt;BR /&gt;| stats count(eval(like(response_code,"%%%"))) AS total_request count(eval(like(response_code,"4%%"))) AS error_request4 count(eval(like(response_code,"5%%"))) AS error_request5 by tenant&lt;BR /&gt;| eval pass_percent = round(100-((error_request4+error_request5)/total_request*100),2) | where total_request &amp;gt;1&lt;BR /&gt;| table tenant, pass_percent, total_request | sort -pass_percent limit=3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And&lt;/P&gt;
&lt;P&gt;index="gtw-ilb" /v1/platform/change_indicators host="*dev01*"| search sourcetype="nginx:plus:access" |eval env = mvindex(split(host, "-"), 1)&lt;BR /&gt;| convert num(status) as response_code&lt;BR /&gt;| eval env = mvindex(split(host, "-"), 1) |eval tenant=split(access_request, "tenantId=")| eval tenant=mvindex(tenant, 1) | eval tenant=split(tenant, "&amp;amp;#38;") | eval tenant=mvindex(tenant, 0)&lt;BR /&gt;| stats count(eval(like(response_code,"%%%"))) AS total_request count(eval(like(response_code,"4%%"))) AS error_request4 count(eval(like(response_code,"5%%"))) AS error_request5 by tenant&lt;BR /&gt;| eval pass_percent = round(100-((error_request4+error_request5)/total_request*100),2) | where total_request &amp;gt;1&lt;BR /&gt;| table tenant, pass_percent, total_request | sort -total_request limit=10&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These 2 queries have 90% search criteria common except&amp;nbsp;sorting by column&lt;/P&gt;
&lt;P&gt;I want to union of two in one query and extract even duplicate result, what will be that one query please?&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2022 16:25:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-get-union-of-two-in-one-query-and-extract-even-duplicate/m-p/593392#M48656</guid>
      <dc:creator>dezmadi</dc:creator>
      <dc:date>2022-04-12T16:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: Union of two queries</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-get-union-of-two-in-one-query-and-extract-even-duplicate/m-p/593396#M48657</link>
      <description>&lt;P&gt;There could be a more practical way like re-using results from a saved job, but assuming that you really really want to do it in one search, you have to simply prepare your results, sort, count and filter.&lt;/P&gt;&lt;PRE&gt;&amp;lt;your base earch up to:&amp;gt;&lt;BR /&gt;| table tenant pass_percent total_request&lt;BR /&gt;| sort - pass_percent&lt;BR /&gt;| streamstats count as passorder&lt;BR /&gt;| sort -&amp;nbsp; total_request&lt;BR /&gt;| streamstats count as totalreqorder&lt;BR /&gt;| where passorder&amp;lt;=3 AND totalreqorder &amp;lt;=10&lt;/PRE&gt;&lt;P&gt;Now you have only those results that are in either top 3 of pass_percent or top 10 of total_request.&lt;/P&gt;&lt;P&gt;The only downside is that if a results meets both those conditions it's listed only once. If you want it twice, you'd need to duplicate those rows. Something like that:&lt;/P&gt;&lt;PRE&gt;| eval splitter=mvappend(if passorder&amp;lt;=3,"split",null(),if totalreqorder&amp;lt;=10,"split",null())&lt;BR /&gt;| mvexpand splitter&lt;/PRE&gt;&lt;P&gt;I understand you can remove the extra fields on your own &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2022 06:15:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-get-union-of-two-in-one-query-and-extract-even-duplicate/m-p/593396#M48657</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-04-12T06:15:56Z</dc:date>
    </item>
    <item>
      <title>Re: Union of two queries</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-get-union-of-two-in-one-query-and-extract-even-duplicate/m-p/593405#M48658</link>
      <description>&lt;P&gt;Thanks for the quick reply, however there are 2 issues with first query(If I am not applying splitter), 1: I am getting passorder and&amp;nbsp;totalreqorder also as part of table, also with&amp;nbsp;where passorder&amp;lt;=3 AND totalreqorder &amp;lt;=10, I am getting just 3 records&lt;/P&gt;&lt;P&gt;In second query, its saying "&lt;SPAN&gt;Error in 'eval' command: The expression is malformed. Expected ).&lt;/SPAN&gt;" However format seems to be correct&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2022 07:06:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-get-union-of-two-in-one-query-and-extract-even-duplicate/m-p/593405#M48658</guid>
      <dc:creator>dezmadi</dc:creator>
      <dc:date>2022-04-12T07:06:08Z</dc:date>
    </item>
    <item>
      <title>Re: Union of two queries</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-get-union-of-two-in-one-query-and-extract-even-duplicate/m-p/593417#M48659</link>
      <description>&lt;P&gt;Bah. My bad. I was writing it on my tablet, without splunk at hand to verify, and mixed different syntaxes &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The "if" command indeed lacks parentheses&lt;/P&gt;&lt;PRE&gt;| eval splitter=mvappend(if(passorder&amp;lt;=3,"split",null()),if(totalreqorder&amp;lt;=10,"split",null()))&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Apr 2022 08:26:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-get-union-of-two-in-one-query-and-extract-even-duplicate/m-p/593417#M48659</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-04-12T08:26:37Z</dc:date>
    </item>
    <item>
      <title>Re: Union of two queries</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-get-union-of-two-in-one-query-and-extract-even-duplicate/m-p/593420#M48660</link>
      <description>&lt;P&gt;Cheers , it works now, Any suggestion how can we remove&amp;nbsp;passorder, splitter and&amp;nbsp;totalreqorder from table, we don't want those&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2022 08:41:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-get-union-of-two-in-one-query-and-extract-even-duplicate/m-p/593420#M48660</guid>
      <dc:creator>dezmadi</dc:creator>
      <dc:date>2022-04-12T08:41:46Z</dc:date>
    </item>
    <item>
      <title>Re: Union of two queries</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-get-union-of-two-in-one-query-and-extract-even-duplicate/m-p/593423#M48661</link>
      <description>&lt;PRE&gt;| fields - passorder and so on &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Apr 2022 09:47:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-get-union-of-two-in-one-query-and-extract-even-duplicate/m-p/593423#M48661</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-04-12T09:47:10Z</dc:date>
    </item>
  </channel>
</rss>

