<?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: Need help with doing math over 2 columns names which keep changing in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Need-help-with-doing-math-over-2-columns-names-which-keep/m-p/309432#M4104</link>
    <description>&lt;P&gt;Is the field literally 'Total:BLAH'  'Yes:BLAH'  or 'Total:FOO' 'Yes:FOO'  or 'Total:BAR' 'Yes:BAR'  ?&lt;/P&gt;

&lt;P&gt;because then it should work... that's what the wild cards are for. &lt;/P&gt;

&lt;P&gt;You may want to explore the data and test that the pattern of field NAMES is what you think they are...&lt;BR /&gt;
just to be sure...&lt;/P&gt;</description>
    <pubDate>Sat, 31 Mar 2018 23:01:58 GMT</pubDate>
    <dc:creator>rsennett_splunk</dc:creator>
    <dc:date>2018-03-31T23:01:58Z</dc:date>
    <item>
      <title>Need help with doing math over 2 columns names which keep changing</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Need-help-with-doing-math-over-2-columns-names-which-keep/m-p/309428#M4100</link>
      <description>&lt;P&gt;i have 2 columns which keep changing their names. but the first few parts remain same.&lt;BR /&gt;
ex:&lt;BR /&gt;
column1 :  Total: ABC   , the ABC part keeps changing&lt;BR /&gt;
column2 : Yes : ABC, the ABC part keeps changing.&lt;/P&gt;

&lt;P&gt;both these columns have numbers and i want to multiply both these values to a new column.&lt;BR /&gt;
|eval Comp= Total: ABC * Yes: ABC&lt;/P&gt;

&lt;P&gt;how do i do this, while retaining the original column names..&lt;BR /&gt;
i just need the Comp to be calculated...&lt;/P&gt;</description>
      <pubDate>Sat, 31 Mar 2018 21:19:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Need-help-with-doing-math-over-2-columns-names-which-keep/m-p/309428#M4100</guid>
      <dc:creator>jiaqya</dc:creator>
      <dc:date>2018-03-31T21:19:47Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with doing math over 2 columns names which keep changing</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Need-help-with-doing-math-over-2-columns-names-which-keep/m-p/309429#M4101</link>
      <description>&lt;P&gt;I fully admit to being no expert in the use of FOREACH, but this is what you are looking for.&lt;BR /&gt;
What I am not totally clear on is whether ABC represents a matching suffix or if they could be Total:ABC and Yes:DEF&lt;/P&gt;

&lt;P&gt;The code below presumes they are the same &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...|foreach Total:* [eval "new_&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;" = '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;' + 'Yes:&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;']
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The brackets are a sub search...  so this says:&lt;BR /&gt;
make a new field that is called new_sameasprefix and contains the sum of the field outside the sub search and this other field with the same prefix FOR EACH time a field looks like this: Total:*&lt;/P&gt;

&lt;P&gt;Worth taking a look at the doc for &lt;A href="http://docs.splunk.com/Documentation/Splunk/7.0.3/SearchReference/Foreach"&gt;foreach&lt;/A&gt; and seeing if that solves your problem.  Read through the Optional argument section to absorb the concept of &lt;CODE&gt;&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;&lt;/CODE&gt; and how they are applied to the wild card.&lt;/P&gt;</description>
      <pubDate>Sat, 31 Mar 2018 22:48:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Need-help-with-doing-math-over-2-columns-names-which-keep/m-p/309429#M4101</guid>
      <dc:creator>rsennett_splunk</dc:creator>
      <dc:date>2018-03-31T22:48:49Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with doing math over 2 columns names which keep changing</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Need-help-with-doing-math-over-2-columns-names-which-keep/m-p/309430#M4102</link>
      <description>&lt;P&gt;Total: ABC  and Yes: ABC , these 2 would always match as these are coming from a previous "by text" query.&lt;BR /&gt;
if the ABC changes to DEF, then it would be Total: DEF &amp;amp; Yes: DEF&lt;/P&gt;

&lt;P&gt;yes, these are the same for a single row.&lt;BR /&gt;
let me try and see...&lt;/P&gt;</description>
      <pubDate>Sat, 31 Mar 2018 22:53:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Need-help-with-doing-math-over-2-columns-names-which-keep/m-p/309430#M4102</guid>
      <dc:creator>jiaqya</dc:creator>
      <dc:date>2018-03-31T22:53:03Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with doing math over 2 columns names which keep changing</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Need-help-with-doing-math-over-2-columns-names-which-keep/m-p/309431#M4103</link>
      <description>&lt;P&gt;This does not look to be working for me.&lt;BR /&gt;
the part ABC DEF , could keep changing...&lt;/P&gt;

&lt;P&gt;i would also be ok, if i could rename all the Total:*  as Total &amp;amp; Yes:* as Yes , without the * , that allows me to do eval for the calculation..&lt;BR /&gt;
is this possible..&lt;/P&gt;</description>
      <pubDate>Sat, 31 Mar 2018 22:58:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Need-help-with-doing-math-over-2-columns-names-which-keep/m-p/309431#M4103</guid>
      <dc:creator>jiaqya</dc:creator>
      <dc:date>2018-03-31T22:58:16Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with doing math over 2 columns names which keep changing</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Need-help-with-doing-math-over-2-columns-names-which-keep/m-p/309432#M4104</link>
      <description>&lt;P&gt;Is the field literally 'Total:BLAH'  'Yes:BLAH'  or 'Total:FOO' 'Yes:FOO'  or 'Total:BAR' 'Yes:BAR'  ?&lt;/P&gt;

&lt;P&gt;because then it should work... that's what the wild cards are for. &lt;/P&gt;

&lt;P&gt;You may want to explore the data and test that the pattern of field NAMES is what you think they are...&lt;BR /&gt;
just to be sure...&lt;/P&gt;</description>
      <pubDate>Sat, 31 Mar 2018 23:01:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Need-help-with-doing-math-over-2-columns-names-which-keep/m-p/309432#M4104</guid>
      <dc:creator>rsennett_splunk</dc:creator>
      <dc:date>2018-03-31T23:01:58Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with doing math over 2 columns names which keep changing</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Need-help-with-doing-math-over-2-columns-names-which-keep/m-p/309433#M4105</link>
      <description>&lt;P&gt;Hi, here is the command i ran , but i get an error , i just tried to remove the : to make it even more clear.&lt;/P&gt;

&lt;P&gt;: AGUA is the dynamic entry&lt;/P&gt;

&lt;P&gt;| foreach Total* [eval Comp&amp;lt;&amp;gt; = &amp;lt;&amp;gt; + Yes&amp;lt;&amp;gt;]&lt;BR /&gt;
Failed to parse templatized search for field 'Total: AGUA'&lt;/P&gt;

&lt;P&gt;i am expecting the answer to be Comp: AGUA=sum of Total* and Yes* , is that right..&lt;/P&gt;</description>
      <pubDate>Sat, 31 Mar 2018 23:11:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Need-help-with-doing-math-over-2-columns-names-which-keep/m-p/309433#M4105</guid>
      <dc:creator>jiaqya</dc:creator>
      <dc:date>2018-03-31T23:11:08Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with doing math over 2 columns names which keep changing</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Need-help-with-doing-math-over-2-columns-names-which-keep/m-p/309434#M4106</link>
      <description>&lt;P&gt;take a look at the doc. it's confusing... but the &lt;CODE&gt;&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;&lt;/CODE&gt; and &lt;CODE&gt;&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;&lt;/CODE&gt; is literal... not a place holder.  so:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...|foreach Total:* [eval &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt; = &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; + Yes:&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;so when Total:AGUA and Yes:AGUA occur, for each Total:AGUA you get a new field called AGUA that is the sum of the original field, Total:AGUA and the other one... Yes:AGUA.&lt;/P&gt;</description>
      <pubDate>Sat, 31 Mar 2018 23:15:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Need-help-with-doing-math-over-2-columns-names-which-keep/m-p/309434#M4106</guid>
      <dc:creator>rsennett_splunk</dc:creator>
      <dc:date>2018-03-31T23:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with doing math over 2 columns names which keep changing</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Need-help-with-doing-math-over-2-columns-names-which-keep/m-p/309435#M4107</link>
      <description>&lt;P&gt;Since the field names contains special characters, include appropriate quotes around it.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...|foreach Total:* [eval "new_&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;" = '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;' + 'Yes:&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;']
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 01 Apr 2018 05:11:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Need-help-with-doing-math-over-2-columns-names-which-keep/m-p/309435#M4107</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-04-01T05:11:35Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with doing math over 2 columns names which keep changing</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Need-help-with-doing-math-over-2-columns-names-which-keep/m-p/309436#M4108</link>
      <description>&lt;P&gt;Thanks Somesoni, that is what i was missing previously, that worked perfectly now..&lt;/P&gt;

&lt;P&gt;and thanks rsennett for the direction...&lt;/P&gt;

&lt;P&gt;John.&lt;/P&gt;</description>
      <pubDate>Sun, 01 Apr 2018 05:28:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Need-help-with-doing-math-over-2-columns-names-which-keep/m-p/309436#M4108</guid>
      <dc:creator>jiaqya</dc:creator>
      <dc:date>2018-04-01T05:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with doing math over 2 columns names which keep changing</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Need-help-with-doing-math-over-2-columns-names-which-keep/m-p/309437#M4109</link>
      <description>&lt;P&gt;oh gosh. sorry. upvoted somesoni2's comment. Funny, I just answered another question with that very fact... that special characters will usually need to be wrapped in appropriate quotes!  Answer amended for posterity. &lt;/P&gt;</description>
      <pubDate>Sun, 01 Apr 2018 07:11:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Need-help-with-doing-math-over-2-columns-names-which-keep/m-p/309437#M4109</guid>
      <dc:creator>rsennett_splunk</dc:creator>
      <dc:date>2018-04-01T07:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with doing math over 2 columns names which keep changing</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Need-help-with-doing-math-over-2-columns-names-which-keep/m-p/309438#M4110</link>
      <description>&lt;P&gt;Not a issue, i glad my issue is resolved now.. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 01 Apr 2018 07:14:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Need-help-with-doing-math-over-2-columns-names-which-keep/m-p/309438#M4110</guid>
      <dc:creator>jiaqya</dc:creator>
      <dc:date>2018-04-01T07:14:33Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with doing math over 2 columns names which keep changing</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Need-help-with-doing-math-over-2-columns-names-which-keep/m-p/309439#M4111</link>
      <description>&lt;P&gt;And Thanks to you both again....&lt;/P&gt;</description>
      <pubDate>Sun, 01 Apr 2018 07:14:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Need-help-with-doing-math-over-2-columns-names-which-keep/m-p/309439#M4111</guid>
      <dc:creator>jiaqya</dc:creator>
      <dc:date>2018-04-01T07:14:45Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with doing math over 2 columns names which keep changing</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Need-help-with-doing-math-over-2-columns-names-which-keep/m-p/309440#M4112</link>
      <description>&lt;P&gt;For more info that might help others,  i was trying to work with geostats (that is where the : special character  was coming into the column name for each site )  and was wanting to have the compliance calculation done on it. below is the exact query that is working for me now..&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|geostats maxzoomlevel=18 globallimit=0 latfield=Latitude longfield=Longitude avg(g1) as g1 avg(a1) as a1 avg(a2) as a2 avg(c1) as c1 sum(Total) as Total sum(Yes) as Yes  ""
|foreach Total* [eval "Compliance&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;" = ('Yes&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;'/'&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;')*100]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 01 Apr 2018 15:30:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Need-help-with-doing-math-over-2-columns-names-which-keep/m-p/309440#M4112</guid>
      <dc:creator>jiaqya</dc:creator>
      <dc:date>2018-04-01T15:30:57Z</dc:date>
    </item>
  </channel>
</rss>

