<?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 align values in a column with values from another column? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-align-values-in-a-column-with-values-from-another-column/m-p/171895#M49267</link>
    <description>&lt;P&gt;I forgot the &lt;CODE&gt;if&lt;/CODE&gt;s; try this version:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=core (... ne=ne1) OR (... ne=ne2) | stats sum(eval(if((ne==ne1),kpi1,null())) AS "kpi1" sum(eval(if(ne==ne2),kpi1,null())) AS "kpi1_ne2" BY ks_countryname
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 17 Aug 2015 21:34:26 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2015-08-17T21:34:26Z</dc:date>
    <item>
      <title>How to align values in a column with values from another column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-align-values-in-a-column-with-values-from-another-column/m-p/171890#M49262</link>
      <description>&lt;P&gt;I basically have 2 searches that I am combining using &lt;CODE&gt;appendcols&lt;/CODE&gt;. 1 search is for each element. It looks something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=core ... ne=ne1 | stats sum(kpi1) as "kpi1" by ks_countryname | sort - "kpi1" |
appendcols [search index=core ... ne=ne2 | stats sum(kpi1) as "kpi1_ne2" by ks_countryname | rename ks_countryname as  ks_countryname_ne2| sort - "kpi1_ne2"]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;the output looks something like below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ks_countryname  kpi1  kpi1_ne2  ks_countryname_ne2
ZZ_undefined    1615    2631       ZZ_undefined
Australia      1500 1635           China
United States   676 1600         Australia
China           423  410    United States
Vanuatu       295    305           Samoa
Switzerland   220    247        Switzerland
Germany       165    213          Germany
France         157   181        France
Samoa           118   62          Vanuatu
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How do I get column 3 and 4 to line up with column 1 and 2 such that:&lt;BR /&gt;
row 2 of column 1 and 2  &lt;CODE&gt;Australia    1500&lt;/CODE&gt; would line up with row 3 of column 3 and 4 &lt;CODE&gt;1600    Australia&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Ideally I would still like to sort max to min by kpi1, but I just want the countries aligned also.&lt;/P&gt;</description>
      <pubDate>Sun, 16 Aug 2015 23:25:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-align-values-in-a-column-with-values-from-another-column/m-p/171890#M49262</guid>
      <dc:creator>HattrickNZ</dc:creator>
      <dc:date>2015-08-16T23:25:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to align values in a column with values from another column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-align-values-in-a-column-with-values-from-another-column/m-p/171891#M49263</link>
      <description>&lt;P&gt;Do it like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=core ... ne=ne1 | stats sum(kpi1) as "kpi1" by ks_countryname | append [search index=core ... ne=ne2 | stats sum(kpi1) as "kpi1_ne2" by ks_countryname ] | stats values(*) AS * by ks_countryname 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Aug 2015 16:24:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-align-values-in-a-column-with-values-from-another-column/m-p/171891#M49263</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-08-17T16:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to align values in a column with values from another column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-align-values-in-a-column-with-values-from-another-column/m-p/171892#M49264</link>
      <description>&lt;P&gt;don't think this wrks. they don't seem to be lining up correctly. Also what if ks_countryname and ks_countryname_ne2 have different list of names?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 07:01:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-align-values-in-a-column-with-values-from-another-column/m-p/171892#M49264</guid>
      <dc:creator>HattrickNZ</dc:creator>
      <dc:date>2020-09-29T07:01:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to align values in a column with values from another column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-align-values-in-a-column-with-values-from-another-column/m-p/171893#M49265</link>
      <description>&lt;P&gt;Actually, we don't need to use &lt;CODE&gt;append&lt;/CODE&gt; at all and this should be even better and clearer (to give you more confidence that it is doing what you need it to do):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=core (... ne=ne1) OR (... ne=ne2) | stats sum(eval(ne=ne1,kpi1,null())) AS "kpi1" sum(eval(ne=ne2,kpi1,null())) AS "kpi1_ne2" BY ks_countryname
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Aug 2015 20:56:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-align-values-in-a-column-with-values-from-another-column/m-p/171893#M49265</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-08-17T20:56:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to align values in a column with values from another column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-align-values-in-a-column-with-values-from-another-column/m-p/171894#M49266</link>
      <description>&lt;P&gt;&lt;CODE&gt;sum(eval(ne=ne1,kpi1,null()))&lt;/CODE&gt; I am getting an error with this Error in 'stats' command: The eval expression for dynamic field 'eval(ne=ne1,kpi1,null())' is invalid. Error='The operator at ',kpi1,null()' is invalid.'&lt;/P&gt;</description>
      <pubDate>Mon, 17 Aug 2015 21:16:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-align-values-in-a-column-with-values-from-another-column/m-p/171894#M49266</guid>
      <dc:creator>HattrickNZ</dc:creator>
      <dc:date>2015-08-17T21:16:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to align values in a column with values from another column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-align-values-in-a-column-with-values-from-another-column/m-p/171895#M49267</link>
      <description>&lt;P&gt;I forgot the &lt;CODE&gt;if&lt;/CODE&gt;s; try this version:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=core (... ne=ne1) OR (... ne=ne2) | stats sum(eval(if((ne==ne1),kpi1,null())) AS "kpi1" sum(eval(if(ne==ne2),kpi1,null())) AS "kpi1_ne2" BY ks_countryname
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Aug 2015 21:34:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-align-values-in-a-column-with-values-from-another-column/m-p/171895#M49267</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-08-17T21:34:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to align values in a column with values from another column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-align-values-in-a-column-with-values-from-another-column/m-p/171896#M49268</link>
      <description>&lt;P&gt;tks I should have copped that, I think thats the one &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Note i had to use double quotes around &lt;CODE&gt;ne1&lt;/CODE&gt; sum(eval(if((ne=="ne1"),kpi1,null()))&lt;/P&gt;</description>
      <pubDate>Mon, 17 Aug 2015 22:04:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-align-values-in-a-column-with-values-from-another-column/m-p/171896#M49268</guid>
      <dc:creator>HattrickNZ</dc:creator>
      <dc:date>2015-08-17T22:04:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to align values in a column with values from another column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-align-values-in-a-column-with-values-from-another-column/m-p/171897#M49269</link>
      <description>&lt;P&gt;Then you need double-quotes in my solution, too.  Does it work now?&lt;/P&gt;</description>
      <pubDate>Mon, 17 Aug 2015 22:28:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-align-values-in-a-column-with-values-from-another-column/m-p/171897#M49269</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-08-17T22:28:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to align values in a column with values from another column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-align-values-in-a-column-with-values-from-another-column/m-p/171898#M49270</link>
      <description>&lt;P&gt;yep thats the job, tks.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Aug 2015 22:43:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-align-values-in-a-column-with-values-from-another-column/m-p/171898#M49270</guid>
      <dc:creator>HattrickNZ</dc:creator>
      <dc:date>2015-08-17T22:43:52Z</dc:date>
    </item>
  </channel>
</rss>

