<?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: Best way to query for multiple values in one row in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Best-way-to-query-for-multiple-values-in-one-row/m-p/43861#M10349</link>
    <description>&lt;P&gt;This solution is better than mine. Simpler. Guess I use stats so much that chart often slips my mind. And with this it's still possible to append the |search to only display rows that aren't all zero as per my edit.&lt;/P&gt;</description>
    <pubDate>Fri, 24 Aug 2012 19:49:38 GMT</pubDate>
    <dc:creator>johandk</dc:creator>
    <dc:date>2012-08-24T19:49:38Z</dc:date>
    <item>
      <title>Best way to query for multiple values in one row</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Best-way-to-query-for-multiple-values-in-one-row/m-p/43854#M10342</link>
      <description>&lt;P&gt;Just got the splunk pdf guide, moved it to the iPad for some weekend reading, still trying to understand how | separates what, hopefully that will help but I will say it's so confusing, really need to grasp this as the requests from people are coming in all over.   So, I have users hitting our site via an API.  The API has 4 different tokens so I know which application was used (website, iphone, etc.).   I would like to know in the past x time each person and the # of times they hit each one, for example;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;username  -  website  -  iphone  -  android  -  website2&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;
usera                0               2               0                5&lt;/P&gt;

&lt;P&gt;Now, my query currently looks like this;&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;memberLevel="1" AND ApiKey = "123" OR ApiKey = "456" OR ApiKey = "789" OR ApiKey = "000" | top username limit="100" application&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;and the results look like this;&lt;BR /&gt;&lt;BR /&gt;
&lt;STRONG&gt;username  -  application  -  count  -  percentage&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;
usera                 web2              2132         51.232132&lt;/P&gt;

&lt;P&gt;application is a lookup to the apikey field so they see web2 instead of 000, but i am trying to basically count BY application and username.   Any help on this is appreciated.&lt;/P&gt;

&lt;P&gt;************************************************  Updated Comments due to limited reply size ********************************************************&lt;/P&gt;

&lt;P&gt;the results is what's not working.    The OP showed both what I wanted vs the output.  The application has a unique API key by type.  I would like to know each user and count each way he accesses the site.   So I could get username Joe, then 3 logins by a website, 10 by an iphone.  The query provided shows one field application with what I would guess was the last one as opposed to counting each one.   I have a separate query that gives me what I want (broken out) but total by day, not by user but maybe the better example.&lt;/P&gt;

&lt;P&gt;memberLevel="1" AND (ApiKey = "123" OR ApiKey = "456" OR ApiKey = "789" OR ApiKey = "000") | timechart span=1d count BY application.   That output looks like;&lt;/P&gt;

&lt;P&gt;_time  --   web1  --  iphone  --  android  --  web2&lt;BR /&gt;&lt;BR /&gt;
date  -- 1200  --  800  --  982  --  430&lt;/P&gt;

&lt;P&gt;I can look at that and say ok, most people came from web1.  Now I want to remove the date, and just say for the last 7 day's, tell me the top users of the site, broken out;&lt;/P&gt;

&lt;P&gt;username  --   web1  --  iphone  --  android  --  web2&lt;BR /&gt;&lt;BR /&gt;
joe  -- 200  --  5  --  0  --  0&lt;BR /&gt;&lt;BR /&gt;
sam -- 110 --  0 --  5  --  0&lt;/P&gt;

&lt;P&gt;Does it make more sense when I explain it like that?&lt;/P&gt;</description>
      <pubDate>Fri, 24 Aug 2012 16:55:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Best-way-to-query-for-multiple-values-in-one-row/m-p/43854#M10342</guid>
      <dc:creator>lancealotx</dc:creator>
      <dc:date>2012-08-24T16:55:52Z</dc:date>
    </item>
    <item>
      <title>Re: Best way to query for multiple values in one row</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Best-way-to-query-for-multiple-values-in-one-row/m-p/43855#M10343</link>
      <description>&lt;P&gt;I don't really get it - if you do a top username,application you WILL get a count BY each combination of application and username Splunk finds. What's not working?&lt;/P&gt;</description>
      <pubDate>Fri, 24 Aug 2012 17:36:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Best-way-to-query-for-multiple-values-in-one-row/m-p/43855#M10343</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2012-08-24T17:36:43Z</dc:date>
    </item>
    <item>
      <title>Re: Best way to query for multiple values in one row</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Best-way-to-query-for-multiple-values-in-one-row/m-p/43856#M10344</link>
      <description>&lt;P&gt;Sorry you don't get it.  Reply doesn't allow enough txt, so I went into more details with more examples in the original post under a ******* update ******** part.  Feel free to look and maybe it will explain it better.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Aug 2012 18:17:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Best-way-to-query-for-multiple-values-in-one-row/m-p/43856#M10344</guid>
      <dc:creator>lancealotx</dc:creator>
      <dc:date>2012-08-24T18:17:12Z</dc:date>
    </item>
    <item>
      <title>Re: Best way to query for multiple values in one row</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Best-way-to-query-for-multiple-values-in-one-row/m-p/43857#M10345</link>
      <description>&lt;P&gt;Try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;memberLevel="1" AND ApiKey = "123" OR ApiKey = "456" OR ApiKey = "789" OR ApiKey = "000" | stats count(eval(application="web1")) AS web1, count(eval(application="iphone")) AS iPhone by username
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In the docs:&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/4.3.3/SearchReference/Stats"&gt;http://docs.splunk.com/Documentation/Splunk/4.3.3/SearchReference/Stats&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;EDIT:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;memberLevel="1" AND ApiKey = "123" OR ApiKey = "456" OR ApiKey = "789" OR ApiKey = "000" | stats count(eval(application="web1")) AS web1, count(eval(application="iphone")) AS iPhone by username | search NOT (web1=0 AND iPhone=0)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 24 Aug 2012 18:38:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Best-way-to-query-for-multiple-values-in-one-row/m-p/43857#M10345</guid>
      <dc:creator>johandk</dc:creator>
      <dc:date>2012-08-24T18:38:45Z</dc:date>
    </item>
    <item>
      <title>Re: Best way to query for multiple values in one row</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Best-way-to-query-for-multiple-values-in-one-row/m-p/43858#M10346</link>
      <description>&lt;P&gt;Cool, the only negative I see are it's in order by username so there are a lot of zeros.  To fix I could either (in english);&lt;BR /&gt;
 - count the total behind the scenes and sort by that value&lt;BR /&gt;
 - only show where all 4 are not 0&lt;/P&gt;

&lt;P&gt;Not sure how hard that is, but at least with the above, people can look, click the arrows and move along!   Are either the above ones easier or harder?&lt;/P&gt;</description>
      <pubDate>Fri, 24 Aug 2012 18:57:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Best-way-to-query-for-multiple-values-in-one-row/m-p/43858#M10346</guid>
      <dc:creator>lancealotx</dc:creator>
      <dc:date>2012-08-24T18:57:15Z</dc:date>
    </item>
    <item>
      <title>Re: Best way to query for multiple values in one row</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Best-way-to-query-for-multiple-values-in-one-row/m-p/43859#M10347</link>
      <description>&lt;P&gt;&lt;CODE&gt;top&lt;/CODE&gt; acts like &lt;CODE&gt;stats&lt;/CODE&gt; in that it gives you one line per pair instead of a matrix which seems to be what you want. &lt;CODE&gt;chart&lt;/CODE&gt; will give a matrix, though. So, this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;memberLevel="1" AND ApiKey = "123" OR ApiKey = "456" OR ApiKey = "789" OR ApiKey = "000" | chart count by username,application
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;should give you what you want, I hope. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Or what johandk suggested works, too.&lt;/P&gt;

&lt;P&gt;EDIT: And if you want to sort by tha total value, add &lt;CODE&gt;| addtotals&lt;/CODE&gt; at the end. This will give you a field called "Total" at the end of each line, that you could sort by with &lt;CODE&gt;| sort - Total&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Aug 2012 19:09:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Best-way-to-query-for-multiple-values-in-one-row/m-p/43859#M10347</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2012-08-24T19:09:30Z</dc:date>
    </item>
    <item>
      <title>Re: Best way to query for multiple values in one row</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Best-way-to-query-for-multiple-values-in-one-row/m-p/43860#M10348</link>
      <description>&lt;P&gt;Option 2 is a lot easier. See my edit.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Aug 2012 19:42:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Best-way-to-query-for-multiple-values-in-one-row/m-p/43860#M10348</guid>
      <dc:creator>johandk</dc:creator>
      <dc:date>2012-08-24T19:42:59Z</dc:date>
    </item>
    <item>
      <title>Re: Best way to query for multiple values in one row</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Best-way-to-query-for-multiple-values-in-one-row/m-p/43861#M10349</link>
      <description>&lt;P&gt;This solution is better than mine. Simpler. Guess I use stats so much that chart often slips my mind. And with this it's still possible to append the |search to only display rows that aren't all zero as per my edit.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Aug 2012 19:49:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Best-way-to-query-for-multiple-values-in-one-row/m-p/43861#M10349</guid>
      <dc:creator>johandk</dc:creator>
      <dc:date>2012-08-24T19:49:38Z</dc:date>
    </item>
  </channel>
</rss>

