<?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: Combine data across multiple sources and then split answer to separate rows when exported to csv in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Combine-data-across-multiple-sources-and-then-split-answer-to/m-p/416354#M73556</link>
    <description>&lt;P&gt;If there were only one, you could use this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| mvexpand FieldJ
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For multiple mv fields, you need to do this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval CountI=coalesce(mvcount(FieldI),0)+1
| eval CountJ=coalesce(mvcount(FieldJ),0)+1
| eval MyFan=if(CountI&amp;gt;CountJ,CountI,CountJ)
| mvexpand MyFan
| eval FieldI=mvindex(FieldI,MyFan)
| eval FieldJ=mvindex(FieldJ,MyFan)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then just add three more lines for each additional mv field.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval CountI=coalesce(mvcount(FieldI),0)+1
| eval CountJ=coalesce(mvcount(FieldJ),0)+1
| eval MyFan=if(CountI&amp;gt;CountJ,CountI,CountJ)

| eval CountK=coalesce(mvcount(FieldK),0)+1
| eval MyFan=if(MyFan&amp;gt;CountK,MyFan,CountK)

| mvexpand MyFan
| eval FieldI=mvindex(FieldI,MyFan)
| eval FieldJ=mvindex(FieldJ,MyFan)

| eval FieldK=mvindex(FieldK,MyFan)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 21 Aug 2018 18:41:25 GMT</pubDate>
    <dc:creator>DalJeanis</dc:creator>
    <dc:date>2018-08-21T18:41:25Z</dc:date>
    <item>
      <title>Combine data across multiple sources and then split answer to separate rows when exported to csv</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Combine-data-across-multiple-sources-and-then-split-answer-to/m-p/416351#M73553</link>
      <description>&lt;P&gt;Good afternoon,&lt;/P&gt;

&lt;P&gt;I am trying to take data from multiple sourcestypes, combine it by a common field and then output it to one entry per line when exporting to CSV. I'm having difficulty because there are several fields but only a couple have multiple values. The fields with multiple values show up in one cell.  I have tried several suggestions I have come across in searching, but none of them seem to do what I'm attempting. &lt;/P&gt;

&lt;P&gt;To start with, another organization hosts the SPLUNK instance, so I do not have access to any back end modifications such as props.conf.  I am able to run searches and create dashboards, that is about it. &lt;/P&gt;

&lt;P&gt;We have 1 index assigned to this data, and 4 source types. The data I need is spread across all 4 source types and there is one common field (key) between the four. Three of the four source types will return a single event per key, but the 4th can return multiple events per key. When I run my search using stats, I get the data from the first three pretty in a line, then the fields from the fourth will have multiple lines per row. When exported, these show up as a single cell in excel.  Hope this makes sense. &lt;/P&gt;

&lt;P&gt;Example: &lt;/P&gt;

&lt;P&gt;Sourcetype1 contains Fielda Fieldb  Fieldc&lt;BR /&gt;
Sourcetype2 contains Fielda Fieldd  Fielde&lt;BR /&gt;
Sourcetype3 contains Fielda Fieldf  Fieldg&lt;BR /&gt;
Sourcetype4 contains Fielda FieldH  FieldI FieldJ&lt;/P&gt;

&lt;P&gt;index=* [search index=* Search_criteria | table Fielda | rename Fielda as query] |stats values(*) as * by Fielda &lt;BR /&gt;
| stats list(Fieldb) as Fieldb, list(Fieldc) as Filedc, list(fieldd) as Fieldd, list(fielde) as Fielde, list(fieldf) as Fieldf, list(Fieldg) as Fieldg, list(FieldH) as FieldH, list(FieldI) as FieldI, list(FieldJ) as FieldJ by Fielda&lt;/P&gt;

&lt;P&gt;Result would look like: &lt;/P&gt;

&lt;P&gt;Fieldb  Fieldc  Fieldd  Fielde  Fieldf  Fieldg  FieldH  FieldI  FieldJ&lt;BR /&gt;
A1          A1          A1          A1          A1          A1          A1          A1          A1&lt;BR /&gt;
                                                                                    A1.1    A1.1&lt;/P&gt;

&lt;P&gt;A2          A2           A2        A2          A2           A2          A2          A2          A2&lt;BR /&gt;
                                                                                    A2.1    A2.1&lt;BR /&gt;
                                                                                    A2.2    A2.2&lt;/P&gt;

&lt;P&gt;A3           A3         A3         A3          A3           A3           A3         A3          A3&lt;/P&gt;

&lt;P&gt;A4           A4         A4         A4          A4           A4           A4         A4          A4&lt;/P&gt;

&lt;P&gt;A5           A5         A5         A5          A5           A5          A5          A5           A5&lt;BR /&gt;
                                                                                    A5.1    A5.1&lt;BR /&gt;
                                                                                    A5.2    A5.2&lt;/P&gt;

&lt;P&gt;And I need it to look like this when exported to CSV: &lt;/P&gt;

&lt;P&gt;Fieldb  Fieldc  Fieldd  Fielde  Fieldf  Fieldg  FieldH  FieldI  FieldJ&lt;BR /&gt;
A1          A1          A1          A1          A1          A1          A1          A1          A1&lt;BR /&gt;
A1          A1          A1          A1          A1          A1          A1          A1.1    A1.1&lt;BR /&gt;
A2          A2           A2        A2          A2           A2          A2          A2          A2&lt;BR /&gt;
A2          A2           A2        A2          A2           A2          A2            A2.1  A2.1&lt;BR /&gt;
A2          A2           A2        A2          A2           A2          A2            A2.2  A2.2&lt;BR /&gt;
A3           A3         A3         A3          A3           A3           A3         A3          A3&lt;BR /&gt;
A4           A4         A4         A4          A4           A4           A4         A4          A4&lt;BR /&gt;
A5           A5         A5         A5          A5           A5          A5          A5           A5&lt;BR /&gt;
A5           A5         A5         A5          A5           A5          A5            A5.1  A5.1&lt;BR /&gt;
A5           A5         A5         A5          A5           A5          A5            A5.2  A5.2&lt;/P&gt;

&lt;P&gt;I've tried using transaction instead of the stats command. I've also tried adding "by fiedla FieldI FieldJ" at the end of the stats and that just seems to created multiple entries for each possible combination of .1 and .2 answers. Any help that could be offered would be greatly appreciated. &lt;/P&gt;</description>
      <pubDate>Mon, 20 Aug 2018 21:49:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Combine-data-across-multiple-sources-and-then-split-answer-to/m-p/416351#M73553</guid>
      <dc:creator>newill</dc:creator>
      <dc:date>2018-08-20T21:49:08Z</dc:date>
    </item>
    <item>
      <title>Re: Combine data across multiple sources and then split answer to separate rows when exported to csv</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Combine-data-across-multiple-sources-and-then-split-answer-to/m-p/416352#M73554</link>
      <description>&lt;P&gt;I just realized how horrible that example turned out after I hit save. Let me try a picture. &lt;/P&gt;

&lt;P&gt;&lt;IMG src="http://i63.tinypic.com/2nkorwg.jpg" alt="alt text" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Aug 2018 15:29:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Combine-data-across-multiple-sources-and-then-split-answer-to/m-p/416352#M73554</guid>
      <dc:creator>newill</dc:creator>
      <dc:date>2018-08-21T15:29:47Z</dc:date>
    </item>
    <item>
      <title>Re: Combine data across multiple sources and then split answer to separate rows when exported to csv</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Combine-data-across-multiple-sources-and-then-split-answer-to/m-p/416353#M73555</link>
      <description>&lt;P&gt;If you put four spaces to the left of your code, the interface will leave them alone.  You can also mark them with the code button on your browser (101 010)&lt;/P&gt;</description>
      <pubDate>Tue, 21 Aug 2018 18:33:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Combine-data-across-multiple-sources-and-then-split-answer-to/m-p/416353#M73555</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2018-08-21T18:33:44Z</dc:date>
    </item>
    <item>
      <title>Re: Combine data across multiple sources and then split answer to separate rows when exported to csv</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Combine-data-across-multiple-sources-and-then-split-answer-to/m-p/416354#M73556</link>
      <description>&lt;P&gt;If there were only one, you could use this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| mvexpand FieldJ
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For multiple mv fields, you need to do this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval CountI=coalesce(mvcount(FieldI),0)+1
| eval CountJ=coalesce(mvcount(FieldJ),0)+1
| eval MyFan=if(CountI&amp;gt;CountJ,CountI,CountJ)
| mvexpand MyFan
| eval FieldI=mvindex(FieldI,MyFan)
| eval FieldJ=mvindex(FieldJ,MyFan)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then just add three more lines for each additional mv field.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval CountI=coalesce(mvcount(FieldI),0)+1
| eval CountJ=coalesce(mvcount(FieldJ),0)+1
| eval MyFan=if(CountI&amp;gt;CountJ,CountI,CountJ)

| eval CountK=coalesce(mvcount(FieldK),0)+1
| eval MyFan=if(MyFan&amp;gt;CountK,MyFan,CountK)

| mvexpand MyFan
| eval FieldI=mvindex(FieldI,MyFan)
| eval FieldJ=mvindex(FieldJ,MyFan)

| eval FieldK=mvindex(FieldK,MyFan)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Aug 2018 18:41:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Combine-data-across-multiple-sources-and-then-split-answer-to/m-p/416354#M73556</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2018-08-21T18:41:25Z</dc:date>
    </item>
    <item>
      <title>Re: Combine data across multiple sources and then split answer to separate rows when exported to csv</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Combine-data-across-multiple-sources-and-then-split-answer-to/m-p/416355#M73557</link>
      <description>&lt;P&gt;I added this, now fieldI is blank and FieldJ still has multiple values. I don't really understand what this code is doing. FieldI and Field J will always have the same count as they are tied together in that sourcetype. &lt;/P&gt;</description>
      <pubDate>Tue, 21 Aug 2018 19:10:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Combine-data-across-multiple-sources-and-then-split-answer-to/m-p/416355#M73557</guid>
      <dc:creator>newill</dc:creator>
      <dc:date>2018-08-21T19:10:05Z</dc:date>
    </item>
  </channel>
</rss>

