5 Replies Latest reply on Apr 6, 2009 3:38 PM by LarsVandegraaf

    Count of transactions per day



      Count of transactions per day


      I would like to set a counter per day, new day counter should reset to 1 for the first transaction.  I thought about an if statement but I don't know how to create a test for current field contents and previous field contents.


      Any help would be appreciated and is there a book witch explains these functions with examples?



        • 1. Re: Count of transactions per day

          Try this, I haven't tested this... 


          Go to Layout ( ... ) // important to set context, even if not really needed, as a precaution

          Go to Record/Request/Page ( Previous )

          Set Variable ( $ CreationDateLastRecord; Value: TableOne :: CreationDateField )

          Go to Record/Request/Page ( Next )  

          # what's missing here is a test for when the year rolls over   

          If ( DayOfYear ( Get ( Current Date ) ) > DayOfYear ( $ CreationDateLastRecord )

            Set Field ( TableOne :: giveUsOurDailyCount ; 1 ) // "1" is our calculated result that we specify in ScriptMaker

            Set Variable ( $ DailyCount; Value: 1 ) 


            Set Variable ( $ DailyCount; Value: $ DailyCount = $ DailyCount + 1 )

            Set Field ( TableOne :: giveUsOurDailyCount ;  $ DailyCount )

          End If


          • 2. Re: Count of transactions per day

            Hello Obeechi,


            I created this script changing the parts that were table::field specific.  I also changed the current date to a field in my table called delivery date.  As delivery date and current date are never the same due to lazy employees :)    The bottom line is the script looks like it goes into a infinite loop.


            Perhaps I made some assumptions, I assumed I should trigger this script on object enter into the transaction per day field of the data entry layout that I created.


            After the infinite looping event, I decided to use your original suggestion using the Get (Current Date) function it also went into a infinite loop. 


            I learned quite a bit on how to use many of these functions, syntax and the tyrannical script editting GUI.


            • 3. Re: Count of transactions per day
              I did some searching on  the internet and I found a better description w/ examples for the Filemaker functions. From this work I developed the answer that worked.  All I needed to do was create a counter field in the table set as a calculation:
              If ( GetNthRecord ( Delivery Date;Get ( RecordNumber )) = GetNthRecord (Delivery Date; Get( RecordNumber ) - 1 ) ; GetNthRecord ( DATE DUMP COUNTER 2;Get ( RecordNumber ) - 1 ) + 1; 1 ) 
              This counter is dependent on the order of records being added, but this is the reason I created it so that the data entry people don't have to populate the field.  Filemaker has a target rich environment for enhancements to the Summary Count function.
              PS.  I showed my mom the solution and she said, I was very bright.  She's the bestest. 
              • 4. Re: Count of transactions per day

                I am not your mother, so let me point out two things:





                GetNthRecord ( Delivery Date ; Get ( RecordNumber ) )


                is a  V E R Y  elaborate way to say the same thing as:

                Delivery Date




                Your method has good chances of producing duplicate numbers in a multi-user environment. If two users are creating a new record at roughly the same time, they do not "see" each other's effort until they commit their records - and then it's too late.


                You should also consider what happens when a record is deleted, or when user enters the wrong date by mistake and needs to correct it, and so on. 

                • 5. Re: Count of transactions per day

                  Hi Sunshine,


                  1)  I use the extra qualifiers b/c I am the kind of guy that wears suspenders and a belt, I dont take chances; plus I wanted to draw out any lurkers that are smart enough to comment but too shy to help on the original post,  Go YOU!


                  2) Only have one data entry person and I have an override system set up.   Thanks for the critique,  I also created a system to check for voids.   I may be hiring a QA person in the future. LOL




                  PS.  This forum is great for fixing the easy answers that can be easily found by RTFM.