PoshCode Logo PowerShell Code Repository

Get-GrowthRate (modification of post by halr9000 view diff)
diff | embed code: <script type="text/javascript" src="http://PoshCode.org/embed/704"></script>download | new post

Calculates percentage growth rate given a starting value, ending value, and number of periods in the range. stahler thx! Corrected period variable name - djryan

  1. function Get-GrowthRate {
  2.         param( $Start, $End, $Period )
  3.         $rate = [math]::Abs( [math]::Pow( ( $End / $Start ),( 1 / $Period - 1 ) ) - 1 )
  4.         "{0:P}" -f $rate
  5. }

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me