<?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: Math Within addtotals in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Math-Within-addtotals/m-p/324829#M96876</link>
    <description>&lt;P&gt;will the following work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | addtotals col=true labelfield=Employee Label="Totals" posibleHours Billable NonBillable totWorked
 |eval perBill=if(Employee="Totals",round(Billable / totworked,2)*100."%",perBill."%")
 |eval perNonBill=if(Employee="Totals",round(NonBillable / totWorked,2)*100."%",perNonBill."%")
 |eval perWorked=if(Employee="Totals",round(possibleHours / totWorked,2)*100."%",perWorked."%")
 | sort -perBill
 | eval HireDate=strftime(HireDate,"%m/%d/%Y")
 | rename "Billing Class" as "Job Title", posibleHours as "Possible Hrs Worked", Billable as "Billable Time", NonBillable as "Non Billable time", totWorked as "Total Hrs Worked", perBill as "% Billable Time Worked", perNonBill as "% Non Billable Time Worked", perWorked as "Total % of time Worked", HireDate as "Date Hired"
 | fields Employee, "Job Title", "Date Hired", "Possible Hrs Worked", "Billable Time", "Non Billable time", "Total Hrs Worked", "% Billable Time Worked", "% Non Billable Time Worked", "Total % of time Worked"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 06 Sep 2017 17:34:45 GMT</pubDate>
    <dc:creator>cmerriman</dc:creator>
    <dc:date>2017-09-06T17:34:45Z</dc:date>
    <item>
      <title>Math Within addtotals</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Math-Within-addtotals/m-p/324828#M96875</link>
      <description>&lt;P&gt;I'm trying to do some math with the values calculated in the addtotals command and put them back into the same line but I can't seem to figure out how to do that.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval daysEmployed = round((end - HireDate)/86400,0)
| eval daysCanWork = if(HireDate &amp;lt;= start, numWorkDay, round((daysEmployed/7)*5,0))
| eval posibleHours=(daysCanWork-numHolidays) * 8
| eval totWorked=Billable+NonBillable
| eval perBill=Billable/posibleHours
| eval perNonBill=NonBillable/posibleHours
| eval perWorked=totWorked / posibleHours
| eval Billable=round(Billable,2)
| eval NonBillable=round(NonBillable,2)
| eval totWorked=round(totWorked,2)
| eval perBill=round(perBill,2)*100
| eval perNonBill=round(perNonBill,2)*100
| eval perWorked=round(perWorked,2)*100
| addtotals col=true labelfield=Employee Label="Totals" posibleHours Billable NonBillable totWorked
| eval perWorked=perWorked + "%"
| eval perBill=perBill + "%"
| eval perNonBill=perNonBill + "%"
| sort -perBill
| eval HireDate=strftime(HireDate,"%m/%d/%Y")
| rename "Billing Class" as "Job Title", posibleHours as "Possible Hrs Worked", Billable as "Billable Time", NonBillable as "Non Billable time", totWorked as "Total Hrs Worked", perBill as "% Billable Time Worked", perNonBill as "% Non Billable Time Worked", perWorked as "Total % of time Worked", HireDate as "Date Hired"
| fields Employee, "Job Title", "Date Hired", "Possible Hrs Worked", "Billable Time", "Non Billable time", "Total Hrs Worked", "% Billable Time Worked", "% Non Billable Time Worked", "Total % of time Worked"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'd like to do the following: &lt;/P&gt;

&lt;P&gt;Billable / totworked = perBill&lt;BR /&gt;
NonBillable / totWorked = perNonBill&lt;BR /&gt;
possibleHours / totWorked = perWorked&lt;/P&gt;

&lt;P&gt;If I just add the perBill,perNonBill,perWorked I just get the sums of those columns which is not what I'm trying to acomplish. &lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2017 16:47:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Math-Within-addtotals/m-p/324828#M96875</guid>
      <dc:creator>icrit</dc:creator>
      <dc:date>2017-09-06T16:47:10Z</dc:date>
    </item>
    <item>
      <title>Re: Math Within addtotals</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Math-Within-addtotals/m-p/324829#M96876</link>
      <description>&lt;P&gt;will the following work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | addtotals col=true labelfield=Employee Label="Totals" posibleHours Billable NonBillable totWorked
 |eval perBill=if(Employee="Totals",round(Billable / totworked,2)*100."%",perBill."%")
 |eval perNonBill=if(Employee="Totals",round(NonBillable / totWorked,2)*100."%",perNonBill."%")
 |eval perWorked=if(Employee="Totals",round(possibleHours / totWorked,2)*100."%",perWorked."%")
 | sort -perBill
 | eval HireDate=strftime(HireDate,"%m/%d/%Y")
 | rename "Billing Class" as "Job Title", posibleHours as "Possible Hrs Worked", Billable as "Billable Time", NonBillable as "Non Billable time", totWorked as "Total Hrs Worked", perBill as "% Billable Time Worked", perNonBill as "% Non Billable Time Worked", perWorked as "Total % of time Worked", HireDate as "Date Hired"
 | fields Employee, "Job Title", "Date Hired", "Possible Hrs Worked", "Billable Time", "Non Billable time", "Total Hrs Worked", "% Billable Time Worked", "% Non Billable Time Worked", "Total % of time Worked"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Sep 2017 17:34:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Math-Within-addtotals/m-p/324829#M96876</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-09-06T17:34:45Z</dc:date>
    </item>
    <item>
      <title>Re: Math Within addtotals</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Math-Within-addtotals/m-p/324830#M96877</link>
      <description>&lt;P&gt;That worked flawlessly! Thank you for your help! &lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2017 17:53:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Math-Within-addtotals/m-p/324830#M96877</guid>
      <dc:creator>icrit</dc:creator>
      <dc:date>2017-09-06T17:53:45Z</dc:date>
    </item>
  </channel>
</rss>

