<?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: How to split a column into two based on condition? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-two-based-on-condition/m-p/620471#M215702</link>
    <description>&lt;P&gt;Your table layout example is not clear. Does the dashes between the field values represent artificial delimiters or is it part of the value?&lt;/P&gt;</description>
    <pubDate>Thu, 10 Nov 2022 16:48:17 GMT</pubDate>
    <dc:creator>johnhuang</dc:creator>
    <dc:date>2022-11-10T16:48:17Z</dc:date>
    <item>
      <title>How to split a column into two based on condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-two-based-on-condition/m-p/620445#M215691</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pls consider this subset of data,&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;... - Date - Fruit - Seller - Bad_count - ...&lt;/STRONG&gt;&lt;/P&gt;&lt;P class=""&gt;11/8 - Apple - X - 3&lt;/P&gt;&lt;P class=""&gt;11/8 - Apple - Y - 10&lt;/P&gt;&lt;P class=""&gt;11/8 - Apple - X - 3&lt;/P&gt;&lt;P class=""&gt;11/8 - Apple - Y - 10&lt;/P&gt;&lt;P class=""&gt;11/8 - Orange - Y - 6&lt;/P&gt;&lt;P class=""&gt;11/8 - Orange - X - 1&lt;/P&gt;&lt;P class=""&gt;11/8 - Orange - Y - 6&lt;/P&gt;&lt;P class=""&gt;11/9 - Apple - X - 0&lt;/P&gt;&lt;P class=""&gt;11/9 - Apple - Y - 9&lt;/P&gt;&lt;P class=""&gt;11/9 - Apple - X - 0&lt;/P&gt;&lt;P class=""&gt;11/9 - Orange - X - 7&lt;/P&gt;&lt;P class=""&gt;11/9 - Orange - Y - 2&lt;/P&gt;&lt;P class=""&gt;How to read it =&amp;gt; Row 1: On 11/8 Seller X had 3 bad Apples, Row 8: on 11/9 Seller X had 0 bad Apples.&lt;/P&gt;&lt;P class=""&gt;I would like to reformat the table into this:&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;... - Date - Fruit - &lt;/STRONG&gt;Seller&lt;STRONG&gt; - &lt;/STRONG&gt;Bad_count&lt;STRONG&gt; - X_bad_count - Y_bad_count - ...&lt;/STRONG&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;11/8 - Apple - &lt;/STRONG&gt;X&lt;STRONG&gt; - &lt;/STRONG&gt;3&lt;STRONG&gt; — 3 - 10&lt;/STRONG&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;11/8 - Apple - &lt;/STRONG&gt;Y&lt;STRONG&gt; - &lt;/STRONG&gt;10&lt;STRONG&gt; — 3 - 10&lt;/STRONG&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;11/8 - Apple - &lt;/STRONG&gt;X&lt;STRONG&gt; - &lt;/STRONG&gt;3&lt;STRONG&gt; — 3 - 10&lt;/STRONG&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;11/8 - Apple - &lt;/STRONG&gt;Y&lt;STRONG&gt; - &lt;/STRONG&gt;10&lt;STRONG&gt; — 3 - 10&lt;/STRONG&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;11/8 - Orange - &lt;/STRONG&gt;Y&lt;STRONG&gt; - &lt;/STRONG&gt;6&lt;STRONG&gt; — 1 - 6&lt;/STRONG&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;11/8 - Orange - &lt;/STRONG&gt;X&lt;STRONG&gt; - &lt;/STRONG&gt;1&lt;STRONG&gt; — 1 - 6&lt;/STRONG&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;11/8 - Orange - &lt;/STRONG&gt;Y&lt;STRONG&gt; - &lt;/STRONG&gt;6&lt;STRONG&gt; — 1 - 6&lt;/STRONG&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;11/9 - Apple - &lt;/STRONG&gt;X&lt;STRONG&gt; - &lt;/STRONG&gt;0&lt;STRONG&gt; — 0 - 9&lt;/STRONG&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;11/9 - Apple - &lt;/STRONG&gt;Y&lt;STRONG&gt; - &lt;/STRONG&gt;9&lt;STRONG&gt; — 0 - 9&lt;/STRONG&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;11/9 - Apple - &lt;/STRONG&gt;X&lt;STRONG&gt; - &lt;/STRONG&gt;0&lt;STRONG&gt; — 0 - 9&lt;/STRONG&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;11/9 - Orange - &lt;/STRONG&gt;X&lt;STRONG&gt; - &lt;/STRONG&gt;7&lt;STRONG&gt; — 7 - 2&lt;/STRONG&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;11/9 - Orange - &lt;/STRONG&gt;Y&lt;STRONG&gt; - &lt;/STRONG&gt;2&lt;STRONG&gt; — 7 - 2&lt;/STRONG&gt;&lt;/P&gt;&lt;P class=""&gt;How to read this =&amp;gt; Row 1: On 11/8 for Apples:&amp;nbsp; Seller X had 3 bad count and Seller Y had 10 bad count.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&lt;U&gt;The idea&lt;/U&gt; is to split the Bad_count column into two columns based on the unique combination of Date and Fruit.&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;Any help would be greatly appreciated!&lt;/P&gt;&lt;P class=""&gt;Thanks,&lt;/P&gt;&lt;P class=""&gt;Shrey&lt;/P&gt;&lt;P class=""&gt;PS: 1) There's years of data, many many fruits, and multiple sellers in the original dataset. 2) I've also sorted the sample data by Fruit up there to make it easy to read. 3) Don't worry about the duplicate rows as there are other fields in the dataset as well (meaning, dedup with care).&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 15:09:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-two-based-on-condition/m-p/620445#M215691</guid>
      <dc:creator>shreyp</dc:creator>
      <dc:date>2022-11-10T15:09:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a column into two based on condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-two-based-on-condition/m-p/620448#M215692</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/249760"&gt;@shreyp&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;you could try something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;your_search&amp;gt;
| bin span=1d _time
| eval column=strftime(_time,"%d/%m")."-".Fruit
| chart values(bad_count) AS bad_count OVER column BY Seller&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 15:24:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-two-based-on-condition/m-p/620448#M215692</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-11-10T15:24:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a column into two based on condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-two-based-on-condition/m-p/620450#M215693</link>
      <description>&lt;P&gt;Assuming your fieldnames are:&amp;nbsp;Date, Fruit, Seller, Bad_count&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval {Seller}_bad_count=Bad_count
| eventstats sum(*_bad_count) AS *_bad_count BY Date
| table Date Fruit Seller Bad_count *_bad_count&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 15:44:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-two-based-on-condition/m-p/620450#M215693</guid>
      <dc:creator>johnhuang</dc:creator>
      <dc:date>2022-11-10T15:44:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a column into two based on condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-two-based-on-condition/m-p/620459#M215694</link>
      <description>&lt;P&gt;Hi Giuseppe,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the response. This almost did it!&amp;nbsp;&lt;/P&gt;&lt;P&gt;As expected, the chart command outputs in "column - X_bad_count - Y_bad_count" format. How do I append these two count columns back into the main table? I'm looking for a view that we would get from eventstats kind of command.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Shrey&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 16:21:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-two-based-on-condition/m-p/620459#M215694</guid>
      <dc:creator>shreyp</dc:creator>
      <dc:date>2022-11-10T16:21:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a column into two based on condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-two-based-on-condition/m-p/620462#M215696</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/190794"&gt;@johnhuang&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the response.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The sum command is not helping in this case. I changed it to values() and it seemed to work but only if I filter for a particular Fruit on a particular day.&lt;/P&gt;&lt;P&gt;Sincerely,&lt;/P&gt;&lt;P&gt;Shrey&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 16:24:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-two-based-on-condition/m-p/620462#M215696</guid>
      <dc:creator>shreyp</dc:creator>
      <dc:date>2022-11-10T16:24:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a column into two based on condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-two-based-on-condition/m-p/620466#M215698</link>
      <description>&lt;P&gt;Are the fieldnames Date, Fruit, Seller, Bad_count?&lt;BR /&gt;Could you provide a sample of your data (screenshot)?&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 16:36:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-two-based-on-condition/m-p/620466#M215698</guid>
      <dc:creator>johnhuang</dc:creator>
      <dc:date>2022-11-10T16:36:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a column into two based on condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-two-based-on-condition/m-p/620468#M215700</link>
      <description>&lt;P&gt;I'm sorry, I can't leak the exact data as it is critical to the organization. I've masked the use case and the variable names to the best of my ability. However, I can make it clear that the counts require no aggregation, only the table layout needs to be changed.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 16:43:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-two-based-on-condition/m-p/620468#M215700</guid>
      <dc:creator>shreyp</dc:creator>
      <dc:date>2022-11-10T16:43:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a column into two based on condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-two-based-on-condition/m-p/620471#M215702</link>
      <description>&lt;P&gt;Your table layout example is not clear. Does the dashes between the field values represent artificial delimiters or is it part of the value?&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 16:48:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-two-based-on-condition/m-p/620471#M215702</guid>
      <dc:creator>johnhuang</dc:creator>
      <dc:date>2022-11-10T16:48:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a column into two based on condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-two-based-on-condition/m-p/620472#M215703</link>
      <description>&lt;P&gt;I've put dashes there to indicate the separation between the columns. Input table has 4 columns and the output table should have 6 columns (after adding X_bad_count and Y_bad_count). You could ignore the dashes or replace them with | , if it helps.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 16:53:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-two-based-on-condition/m-p/620472#M215703</guid>
      <dc:creator>shreyp</dc:creator>
      <dc:date>2022-11-10T16:53:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a column into two based on condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-two-based-on-condition/m-p/620477#M215705</link>
      <description>&lt;P&gt;This should match your output.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval data="11/8,Apple,X,3;11/8,Apple,Y,10;11/8,Apple,X,3;11/8,Apple,Y,10;11/8,Orange,Y,6;11/8,Orange,X,1;11/8,Orange,Y,6;11/9,Apple,X,0;11/9,Apple,Y,9;11/9,Apple,X,0;11/9,Orange,X,7;11/9,Orange,Y,2"
| eval data=split(data, ";")
| mvexpand data
| rex field=data "(?&amp;lt;Date&amp;gt;[^,]*)\,(?&amp;lt;Fruit&amp;gt;[^,]*)\,(?&amp;lt;Seller&amp;gt;[^,]*)\,(?&amp;lt;Bad_count&amp;gt;[^,]*)"
| table Date Fruit Seller Bad_count
| eval {Seller}_bad_count=Bad_count
| eventstats max(*_bad_count) AS *_bad_count BY Date Fruit
| table Date Fruit Seller Bad_count *_bad_count&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 17:24:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-two-based-on-condition/m-p/620477#M215705</guid>
      <dc:creator>johnhuang</dc:creator>
      <dc:date>2022-11-10T17:24:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a column into two based on condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-two-based-on-condition/m-p/620480#M215707</link>
      <description>&lt;P&gt;Thanks, I'll try this as well.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 18:00:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-two-based-on-condition/m-p/620480#M215707</guid>
      <dc:creator>shreyp</dc:creator>
      <dc:date>2022-11-10T18:00:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a column into two based on condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-two-based-on-condition/m-p/620481#M215708</link>
      <description>&lt;P&gt;I was able to solve the problem using&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;'s snippet along w/ a left join.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;base_search&amp;gt;
| bin span=1d _time
| eval column=strftime(_time,"%d/%m")."-".Fruit
| join type=left column
[
| &amp;lt;same_base_search&amp;gt;
| bin span=1d _time
| eval column=strftime(_time,"%d/%m")."-".Fruit
| chart values(bad_count) AS bad_count OVER column BY Seller
]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks, all.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 18:05:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-two-based-on-condition/m-p/620481#M215708</guid>
      <dc:creator>shreyp</dc:creator>
      <dc:date>2022-11-10T18:05:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a column into two based on condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-two-based-on-condition/m-p/620484#M215709</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/249760"&gt;@shreyp&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;good for you, see next time!&lt;/P&gt;&lt;P&gt;Ciao and happy splunking&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;P.S.: Karma Points are appreciated by all the contributors &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 19:12:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-two-based-on-condition/m-p/620484#M215709</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-11-10T19:12:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a column into two based on condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-two-based-on-condition/m-p/620505#M215710</link>
      <description>&lt;P&gt;To confirm,&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/190794"&gt;@johnhuang&lt;/a&gt;&amp;nbsp;- your solution works as well! Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 20:20:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-column-into-two-based-on-condition/m-p/620505#M215710</guid>
      <dc:creator>shreyp</dc:creator>
      <dc:date>2022-11-10T20:20:06Z</dc:date>
    </item>
  </channel>
</rss>

