The column to the right has a total of the percentage increase, but I would like to take that total and divide it by the number of rows that made the total. 
 source="im_positions*.csv" sourcetype="stock-Positions:csv"   
    | dedup Symbol  
    | rename "Market Value" as mv  
    | rename "Estimated Gain_Loss" as egl  
     | rex field=mv mode=sed "s/,//"  
     | rex field=egl mode=sed "s/,//"  
     | rex field=Price mode=sed "s/,//"  
    | replace $* with * in Price  
    | replace $* with * in egl  
    | replace N/A with 0 in egl  
    | replace $* with * in mv  
    | replace .000 with * in Quantity  
    | eval originalprice = (mv - egl)/Quantity  
    | eval eglneg=egl  
    | replace - with * in eglneg  
    | replace $* with * in eglneg  
    | replace N/A with 0 in eglneg  
    | eval originalpriceneg = (mv)+(eglneg) 
  | eval originalprice=if(isnull(originalprice), originalpriceneg, originalprice)
| eval Percent = round(((Price - originalprice)/originalprice*100),0)
| table Symbol Description Quantity originalprice Price egl  mv  Percent
| rename originalprice as "Purchased Price"
| rename Price as "Current Price"
| rename mv as "Market Value"
| rename Percent as "Percentage Increase"
| rename  egl as "Estimated Gain_Loss"
| rename Quantity as "# of Shares"
| addcoltotals 
| sort -"Estimated Gain_Loss"
  
    
						
					
					... View more