<?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: MVExpand help in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/MVExpand-help/m-p/71809#M14652</link>
    <description>&lt;P&gt;There is a slightly better way, but it's not perfect either - requires OrderID to be unique, if it is not you need to do another count before the mvexpand to group by that count:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | mvexpand Product | streamstats current=f count by OrderID | eval OrderStatus = mvindex(OrderStatus, count) | eval CompletionCode = mvindex(CompletionCode, count) | fields - count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, you might make it all much easier if you can influence the report itself, to stop it from having multi-valued fields in the first place... that depends on where your data comes from and how you process it.&lt;/P&gt;</description>
    <pubDate>Fri, 22 Mar 2013 19:00:02 GMT</pubDate>
    <dc:creator>martin_mueller</dc:creator>
    <dc:date>2013-03-22T19:00:02Z</dc:date>
    <item>
      <title>MVExpand help</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/MVExpand-help/m-p/71807#M14650</link>
      <description>&lt;P&gt;I asked a question earlier regarding the preformatting of a csv report which several multivalue fields (Preformat Automatic Report - CSV) and was given the suggestion to use mvexpand. I believe that mvexpand will help with the formatting of my report but I have noticed that it seems to work with only 1 field - when I use multiple mvexpand statements I experience the error of constantly repeating lines in my table - for example: my fields could be Order ID, Product, OrderStatus, CompletionCode - OrderID will have only one item but each field after this could have up to 6 items which correspond to each other, i.e.&lt;/P&gt;

&lt;P&gt;OrderID       Product     OrderStatus   CompletionCode&lt;BR /&gt;&lt;BR /&gt;
1234-56       TV          Accepted      567&lt;BR /&gt;&lt;BR /&gt;
              Aerial      Accepted      567&lt;BR /&gt;&lt;BR /&gt;
              Phone       Cancelled     890      &lt;/P&gt;

&lt;P&gt;When I try to use an mvexpand statement for each field, the first item in the Product field and the data in corresponding fields, seems to continuously repeat and none of the other fields, including other order results, appear&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2013 15:15:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/MVExpand-help/m-p/71807#M14650</guid>
      <dc:creator>rlautman</dc:creator>
      <dc:date>2013-03-22T15:15:57Z</dc:date>
    </item>
    <item>
      <title>Re: MVExpand help</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/MVExpand-help/m-p/71808#M14651</link>
      <description>&lt;P&gt;I believe this is what &lt;CODE&gt;mvzip&lt;/CODE&gt; is for, although it's not intuitive at first as to why, and the following is kind of a long way to go for something that feels like it should be simpler.  Maybe someone has a better way, but here goes. &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;mvzip&lt;/CODE&gt; can take two fields at a time,  say Product and OrderStatus,  and zip up the multivalue pairs, creating one multi-valued-field which we might call "ProductAndOrderStatus", whose values are each a comma-separated pair of Product and OrderStatus . &lt;/P&gt;

&lt;P&gt;If we were to do the same thing a second time we could combine our "ProductAndOrderStatus" field with the "CompletionCode" field,  and &lt;EM&gt;then&lt;/EM&gt; if we use mvexpand on the aggregate field, we'll get the right number of rows,  and &lt;EM&gt;then&lt;/EM&gt; with some careful use of split and mvindex, we can get our three fields teased apart again. &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| eval ProductAndOrderStatus=mvzip(Product,OrderStatus) | eval finalCombined=mvzip(ProductAndOrderStatus,CompletionCode) | fields - Product OrderStatus CompletionCode | mvexpand finalCombined | eval finalCombined=split(finalCombined,",") | eval Product=mvIndex(finalCombined,0) | eval OrderStatus=mvindex(finalCombined,1) | eval CompletionCode=mvindex(finalCombined,2) | fields - finalCombined&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I'm kind of giving this answer hoping that someone has a better way, but at least this is a way that I know will work. &lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2013 16:38:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/MVExpand-help/m-p/71808#M14651</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2013-03-22T16:38:05Z</dc:date>
    </item>
    <item>
      <title>Re: MVExpand help</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/MVExpand-help/m-p/71809#M14652</link>
      <description>&lt;P&gt;There is a slightly better way, but it's not perfect either - requires OrderID to be unique, if it is not you need to do another count before the mvexpand to group by that count:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | mvexpand Product | streamstats current=f count by OrderID | eval OrderStatus = mvindex(OrderStatus, count) | eval CompletionCode = mvindex(CompletionCode, count) | fields - count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, you might make it all much easier if you can influence the report itself, to stop it from having multi-valued fields in the first place... that depends on where your data comes from and how you process it.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2013 19:00:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/MVExpand-help/m-p/71809#M14652</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2013-03-22T19:00:02Z</dc:date>
    </item>
    <item>
      <title>Re: MVExpand help</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/MVExpand-help/m-p/71810#M14653</link>
      <description>&lt;P&gt;I have tried this but now have got a number of rows containing only the OrderID - but none of the tags in the xml are empty&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2013 15:21:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/MVExpand-help/m-p/71810#M14653</guid>
      <dc:creator>rlautman</dc:creator>
      <dc:date>2013-04-10T15:21:01Z</dc:date>
    </item>
    <item>
      <title>Re: MVExpand help</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/MVExpand-help/m-p/71811#M14654</link>
      <description>&lt;P&gt;Strange.  I'm not sure what's happened there.  When there's N values of Product in a given row are there always exactly N values of OrderStatus and CompletionCode?&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2013 15:25:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/MVExpand-help/m-p/71811#M14654</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2013-04-10T15:25:33Z</dc:date>
    </item>
  </channel>
</rss>

