<?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 how to expand multi value fields with different values in column values in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/how-to-expand-multi-value-fields-with-different-values-in-column/m-p/448036#M126979</link>
    <description>&lt;P&gt;Dear Experts,&lt;BR /&gt;
Please provide a valuable solution for my problem.&lt;/P&gt;

&lt;P&gt;I am having the fields from JSON which is having multivalue fields as below. In below example Department field having three values and Projects field having 5 values. I want expand this.&lt;/P&gt;

&lt;P&gt;Name   |  EMP NO | Department | projects&lt;BR /&gt;
ABCS    | 1234567 | CS12345678 | PROJ1&lt;BR /&gt;
             |                  | AB12345678 | PROJ2&lt;BR /&gt;
             |                  | AB55555555 | PROJ3&lt;BR /&gt;
             |                  |                         | PROJ4&lt;BR /&gt;
             |                  |                         | PROJ5&lt;/P&gt;

&lt;P&gt;I need output like the below&lt;BR /&gt;
Name   |  EMP NO | Department | projects&lt;BR /&gt;
ABCS    | 1234567 | CS12345678 | PROJ1&lt;BR /&gt;
ABCS    | 1234567 | AB12345678 | PROJ2&lt;BR /&gt;
ABCS    |  1234567| AB55555555 | PROJ3&lt;BR /&gt;
ABCS    | 1234567 |  NULL             | PROJ4&lt;BR /&gt;
ABCS    | 1234567 |  NULL            | PROJ5&lt;/P&gt;</description>
    <pubDate>Wed, 06 Jun 2018 17:39:16 GMT</pubDate>
    <dc:creator>Rajkumarkbm22</dc:creator>
    <dc:date>2018-06-06T17:39:16Z</dc:date>
    <item>
      <title>how to expand multi value fields with different values in column values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-expand-multi-value-fields-with-different-values-in-column/m-p/448036#M126979</link>
      <description>&lt;P&gt;Dear Experts,&lt;BR /&gt;
Please provide a valuable solution for my problem.&lt;/P&gt;

&lt;P&gt;I am having the fields from JSON which is having multivalue fields as below. In below example Department field having three values and Projects field having 5 values. I want expand this.&lt;/P&gt;

&lt;P&gt;Name   |  EMP NO | Department | projects&lt;BR /&gt;
ABCS    | 1234567 | CS12345678 | PROJ1&lt;BR /&gt;
             |                  | AB12345678 | PROJ2&lt;BR /&gt;
             |                  | AB55555555 | PROJ3&lt;BR /&gt;
             |                  |                         | PROJ4&lt;BR /&gt;
             |                  |                         | PROJ5&lt;/P&gt;

&lt;P&gt;I need output like the below&lt;BR /&gt;
Name   |  EMP NO | Department | projects&lt;BR /&gt;
ABCS    | 1234567 | CS12345678 | PROJ1&lt;BR /&gt;
ABCS    | 1234567 | AB12345678 | PROJ2&lt;BR /&gt;
ABCS    |  1234567| AB55555555 | PROJ3&lt;BR /&gt;
ABCS    | 1234567 |  NULL             | PROJ4&lt;BR /&gt;
ABCS    | 1234567 |  NULL            | PROJ5&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jun 2018 17:39:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-expand-multi-value-fields-with-different-values-in-column/m-p/448036#M126979</guid>
      <dc:creator>Rajkumarkbm22</dc:creator>
      <dc:date>2018-06-06T17:39:16Z</dc:date>
    </item>
    <item>
      <title>Re: how to expand multi value fields with different values in column values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-expand-multi-value-fields-with-different-values-in-column/m-p/448037#M126980</link>
      <description>&lt;P&gt;Do post your json - it might be possible to extract the values correctly right away.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jun 2018 22:16:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-expand-multi-value-fields-with-different-values-in-column/m-p/448037#M126980</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2018-06-06T22:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: how to expand multi value fields with different values in column values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-expand-multi-value-fields-with-different-values-in-column/m-p/448038#M126981</link>
      <description>&lt;P&gt;See the below question: same scenario&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/663556/how-to-expand-multi-value-fields-with-different-fo.html?minQuestionBodyLength=80"&gt;https://answers.splunk.com/answers/663556/how-to-expand-multi-value-fields-with-different-fo.html?minQuestionBodyLength=80&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jun 2018 07:16:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-expand-multi-value-fields-with-different-values-in-column/m-p/448038#M126981</guid>
      <dc:creator>Rajkumarkbm2</dc:creator>
      <dc:date>2018-06-07T07:16:05Z</dc:date>
    </item>
    <item>
      <title>Re: how to expand multi value fields with different values in column values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-expand-multi-value-fields-with-different-values-in-column/m-p/448039#M126982</link>
      <description>&lt;P&gt;I start with the assumption that you have a single record that has Name="ABCS", EmpNo="1234567", Department= a multivalue field with three values, Projects= a multivalue field with 5 values.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your search here 
 | table Name EmpNo Department Projects
 | streamstats count as recNo 
 | eval numRecs=If(mvcount(Department)&amp;gt;mvcount(Projects),mvcount(Department),mvcount(Projects)
 | eval myFan=mvrange(0,numRecs)
 | mvexpand myFan
 | eval Department=case(myFan&amp;lt;mvcount(Department),mvindex(Department,myFan), 
     true(),"NULL")
 | eval Projects=case(myFan&amp;lt;mvcount(Department),mvindex(Department,myFan), 
     true(),"NULL")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now you have five separate records as requested.&lt;/P&gt;

&lt;P&gt;The &lt;CODE&gt;recNo&lt;/CODE&gt; field is a record number in case you ever want to put them back together again.  You can also use it (if desired) for break logic.   That could look something like this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your search here 
| table Name EmpNo Department Projects
| streamstats count as recNo 
| eval numRecs=If(mvcount(Department)&amp;gt;mvcount(Projects),mvcount(Department),mvcount(Projects)
| eval nextRec=numRecs+1
| eval myFan=mvrange(0,nextRec)
| mvexpand myFan
| eval Department=case(myFan&amp;lt;mvcount(Department),mvindex(Department,myFan),
    myFan=numRecs,"",
    true(),"NULL")
| eval Projects=case(myFan&amp;lt;mvcount(Department),mvindex(Department,myFan), 
    myFan=numRecs,"", 
    true(),"NULL")
| eval Name=case(myFan=numRecs,"",
    true(),Name)
| eval EmpNo=case(myFan=numRecs,"",
    true(),EmpNo)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Jun 2018 15:34:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-expand-multi-value-fields-with-different-values-in-column/m-p/448039#M126982</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2018-06-07T15:34:57Z</dc:date>
    </item>
  </channel>
</rss>

