Ah thanks Ken & Jim, got it work just perfectly with your help... it always looks so simple when someone else does it!!!

Much appreciated!!
----- Original Message ----- From: "Jim Ault" <[EMAIL PROTECTED]>
To: "How to use Revolution" <[email protected]>
Sent: Thursday, March 15, 2007 10:15 AM
Subject: Re: Dimensional Arrays


A little refinement can get you tallys and averages for reporting:

Ken's example with the following added:

get tData
filter it with ("B444AAA,*,*,2" -- only month 2
put sumFuelKM(it, collectedValues) into collectedValues
-------------------------------------

put  "B444AAA" into tRegNo
put 2 into tMonth
get tData
filter it with ( tRegNo&",*,*, "& tMonth) -- only month 2
put sumFuelKM(it, collectedValues) into collectedValues
--see the sumFuelKM function below

get line 1 of collectedValues
put sum(it) into tTotalLiters
put (tTotalLitres/the number of items init) into tAvgLitres

get line 2 of collectedValues
put sum(it) into tTotalKMs
put ( tTotalKMs/the number of items init) into tAvgKMs

get tTotalLitres && tAvgLitres && tTotalKMs && tAvgKMs
put it into line tMonth

--> repeat for each month, then
put empty into collectedValues
put 3 into tMonth
get tData
filter it with ( tRegNo&",*,*, "& tMonth)  -- only month 3
put sumFuelKM(it, collectedValues) into collectedValues

--------------------

function sumFuelKM pListOfRegNos, collectedValues
  repeat for each line tLine in pListOfRegNos
    put comma & tLiters after line 1 of collectedValues
    put comma & tKMs after line 2 of collectedValues
  end repeat
  return ( collectedValues)
end sumFuelKM
-----------
** caution **
get tData
filter it with "B444AAA,*,*,1*" -- month 1, 10, 11, 12

Sounds like you are headed for report building and cross-tabulation :-)

Jim Ault
Las Vegas

On 3/14/07 11:11 PM, "Ken Ray" <[EMAIL PROTECTED]> wrote:

On Wed, 14 Mar 2007 17:11:36 +0200, Nic Prioleau wrote:

Hi Kev,

Thanks for your feedback however, I managed to get something like this:

regNo,totalFuel,totalKM,month
B456TRF,1000,0,2
B456TRF,150,0,3
B456TRF,0,376,3
B444AAA,50,0,3
B444AAA,340,3000,3
B444AAA,0,600,3

into a variable from my selects... Could you tell me how I can
achieve the same result as I was trying to get before as I have now
eliminated the other arrays I had. It was too messy and because they
did not have the same keys, it was difficult to get an accurate
result.

Basically the same thing, but it's actually easier in this case - you
can take the variable and filter on the regNo (put an asterisk after
the regno so there'll be a match):

  filter tData with "B444AAA*"

And then loop through the resulting filtered lines, extract the items
you're looking for an add them up:

put 0 into tLitres
put 0 into tKMs
repeat for each line tLine in tData
  add (item 2 of tLine) to tLitres
  add (item 3 of tLine) to tKMs
end repeat

HTH,

Ken Ray
Sons of Thunder Software, Inc.
Email: [EMAIL PROTECTED]
Web Site: http://www.sonsothunder.com/
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution



#####################################################################################
This e-mail message has been scanned for Viruses and Content and cleared by MailMarshal
#####################################################################################
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to