<?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: Issue with Macros in Knowledge Management</title>
    <link>https://community.splunk.com/t5/Knowledge-Management/Issue-with-Macros/m-p/96294#M989</link>
    <description>&lt;P&gt;Yes, you need to specify arguments.  Here is a linear tread macro:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eventstats count as numevents sum($x$) as sumX sum($y$) as sumY sum(eval($x$*$y$)) as sumXY sum(eval($x$*$x$)) as sumX2 sum(eval($y$*$y$)) as sumY2 | eval slope=((numevents*sumXY)-(sumX*sumY))/((numevents*sumX2)-(sumX*sumX)) | eval yintercept=
(sumY-(slope*sumX))/numevents | eval newY=(yintercept + (slope*$x$)) | eval R=((numevents*sumXY) - (sumX*sumY))/sqrt(((numevents*sumX2)-(sumX*sumX))*
((numevents*sumY2)-(sumY*sumY))) | eval R2=R*R
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Under 'Argument' on the macro definition page i have x,y as my arguments. You'll see them in the macro definition above surrounded by $ signs like $x$.  When i call this from the search will look like this - `lineartrent(arg1,arg2)` and the args will get pass into the macro for you.  You can then reference fields created or that exist in your macro and use them in further searches or pass them onto another macro etc.&lt;/P&gt;</description>
    <pubDate>Fri, 19 Oct 2012 15:18:00 GMT</pubDate>
    <dc:creator>sdaniels</dc:creator>
    <dc:date>2012-10-19T15:18:00Z</dc:date>
    <item>
      <title>Issue with Macros</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/Issue-with-Macros/m-p/96293#M988</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;

&lt;P&gt;I have a very complex search which I want to break into 2 macros. I did create a macro but didn't mention any arguments or anything else other than the name and definition. Can anyone please help me on where I am doing a mistake. I did go through the documentation about arguments but couldn't understand how to define it properly.&lt;/P&gt;

&lt;P&gt;Here is the first one&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval mybucket=case(date_hour&amp;lt;4,1,date_hour&amp;lt;8,2,date_hour&amp;lt;12,3,date_hour&amp;lt;16,4,date_hour&amp;lt;20,5,date_hour&amp;gt;0,6) | stats count as I by WG, mybucket,date_mday,date_month,date_year
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And the second one is&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;delta I as D  | eval D = abs(D) | eventstats avg(I) as xbar, avg(D) as mbar by WG | eval threshold = xbar + (2.66*mbar) | eval threshold=coalesce(threshold,0) | dedup WG | fields WG threshold | table WG threshold
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Do I need to mention any arguments or give any validation? I did check the use eval-based definition box though. Any help?&lt;/P&gt;

&lt;P&gt;Regards&lt;/P&gt;

&lt;P&gt;theou&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2012 14:23:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/Issue-with-Macros/m-p/96293#M988</guid>
      <dc:creator>theouhuios</dc:creator>
      <dc:date>2012-10-19T14:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Macros</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/Issue-with-Macros/m-p/96294#M989</link>
      <description>&lt;P&gt;Yes, you need to specify arguments.  Here is a linear tread macro:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eventstats count as numevents sum($x$) as sumX sum($y$) as sumY sum(eval($x$*$y$)) as sumXY sum(eval($x$*$x$)) as sumX2 sum(eval($y$*$y$)) as sumY2 | eval slope=((numevents*sumXY)-(sumX*sumY))/((numevents*sumX2)-(sumX*sumX)) | eval yintercept=
(sumY-(slope*sumX))/numevents | eval newY=(yintercept + (slope*$x$)) | eval R=((numevents*sumXY) - (sumX*sumY))/sqrt(((numevents*sumX2)-(sumX*sumX))*
((numevents*sumY2)-(sumY*sumY))) | eval R2=R*R
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Under 'Argument' on the macro definition page i have x,y as my arguments. You'll see them in the macro definition above surrounded by $ signs like $x$.  When i call this from the search will look like this - `lineartrent(arg1,arg2)` and the args will get pass into the macro for you.  You can then reference fields created or that exist in your macro and use them in further searches or pass them onto another macro etc.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2012 15:18:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/Issue-with-Macros/m-p/96294#M989</guid>
      <dc:creator>sdaniels</dc:creator>
      <dc:date>2012-10-19T15:18:00Z</dc:date>
    </item>
  </channel>
</rss>

