Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualParadigm Shifter

Posted 24 July 2013 - 08:56 AM

What they probably need is to track the last quarter value when it is output. The above solution doesn't work for the first quarter of a year (need to compare to last quarter of previous year).

 

Pseudo code:

 

isFirstValue = true

previousValue = 0

 

while moreDataToOutput():

  currentValue = getQuarterlyValue()

  output "sales for this quarter = $" currentValue

  if not isFirstValue output "quarterly increase = $" currentValue - previousValue

  isFirstValue = false

  previousValue = currentValue

end while


#1Paradigm Shifter

Posted 24 July 2013 - 08:55 AM

What they probably need is to track the last quarter value when it is output. The above solution doesn't work for the first quarter of a year (need to compare to last quarter of previous year).

 

Pseudo code:

 

isFirstValue = true

previousValue = 0

 

while moreDataToOutput:

  currentValue = getQuarterlyValue()

  output "sales for this quarter = $" currentValue

  if not isFirstValue output "quarterly increase = $" currentValue - previousValue

  isFirstValue = false

  previousValue = currentValue

end while


PARTNERS