<?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: Multiple occurrences of fields in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Multiple-occurrences-of-fields/m-p/169653#M48497</link>
    <description>&lt;P&gt;As you said you're able to get the fruit, count and price for each line and since they repeat within same event as well, they are multivalued field. try this.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search + rex, giving _time, fruit(mvfield), count,price | eval fruitline=mvzip(fruit,count) | eval fruitline=mvzip(fruitline,price) | table _time, fruitline | mvexpand fruitline | rex field=fruitline "(?&amp;lt;fruit&amp;gt;.*),(?&amp;lt;count&amp;gt;.*),(?&amp;lt;price&amp;gt;.*)"| table _time fruit count price | where fruit="apple" 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 28 Feb 2014 05:15:10 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2014-02-28T05:15:10Z</dc:date>
    <item>
      <title>Multiple occurrences of fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-occurrences-of-fields/m-p/169652#M48496</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I have log lines that look like this [ some silly example but the idea is there &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; ]&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;mm/dd/yyyy hh:mm:ss - fruit: apple count: 5 price: $4 fruit: orange count: 10 price: $10&lt;BR /&gt;
&lt;BR /&gt;mm/dd/yyyy hh:mm:ss - fruit: banana count: 2 price: $1 fruit: orange count: 10 price: $10 fruit: pear count: 8 price: $14&lt;BR /&gt;
&lt;BR /&gt;mm/dd/yyyy hh:mm:ss - fruit: pineapple count: 10 price: $40 fruit: mango count: 1 price: $1&lt;BR /&gt;
&lt;BR /&gt;mm/dd/yyyy hh:mm:ss - fruit: coconut count: 5 price: $8 fruit: apple count: 5 price: $1&lt;/P&gt;

&lt;P&gt;I know how to use rex to grab the fruit, count and price values from each line. There will be variable number of pairs of those values. How do I display the information for apple only using stats or anything by date? &lt;/P&gt;

&lt;P&gt;In my example, only first and last log lines have apple in them. I want to display the count and price of apple for those two dates.&lt;/P&gt;

&lt;P&gt;Appreciate any help.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2014 03:07:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-occurrences-of-fields/m-p/169652#M48496</guid>
      <dc:creator>lain179</dc:creator>
      <dc:date>2014-02-28T03:07:46Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple occurrences of fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-occurrences-of-fields/m-p/169653#M48497</link>
      <description>&lt;P&gt;As you said you're able to get the fruit, count and price for each line and since they repeat within same event as well, they are multivalued field. try this.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search + rex, giving _time, fruit(mvfield), count,price | eval fruitline=mvzip(fruit,count) | eval fruitline=mvzip(fruitline,price) | table _time, fruitline | mvexpand fruitline | rex field=fruitline "(?&amp;lt;fruit&amp;gt;.*),(?&amp;lt;count&amp;gt;.*),(?&amp;lt;price&amp;gt;.*)"| table _time fruit count price | where fruit="apple" 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Feb 2014 05:15:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-occurrences-of-fields/m-p/169653#M48497</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-02-28T05:15:10Z</dc:date>
    </item>
  </channel>
</rss>

