1 Reply Latest reply on Feb 25, 2013 9:10 AM by philmodjunk

    Counting unique serial fields for a graph

      Title

      Counting unique serial fields for a graph

      Post

           Following on from a prev post, I would like to know how to implement the fields below to my 'create graph' script.

            

             
      1.           Define a summary field sTotalCount as Count Of: SerialNumberField
      2.      
      3.           Define a calculation field cFraction as 1 / GetSummary ( sTotalCount ; SerialNumberField )
      4.      
      5.           Define another summary field sUniqueCount as Total Of: cFraction

            

      Sort your records by SerialNumberField and sUniqueCount will give you the correct number of unique values.

            

           I have added these fields to my table, but am unsure how to add them to my graph script. 

           My graph script is below. What I am trying to do, is to count unique job numbers from a long list of invoice records. The search criteria is by a choice of two years, and the X axis of my graph show month names. The field that contains the job number is invoiceheadingjob::Job_no.

           I am just having trouble counting the correct amount of unique Job_no fields, sorted by month.

           I tried applying the sort by job_no and adding sunique count to the Y axis on graph, but it isnt coming out with the correct figures...

      my script:

            

             
      •           Set Error Capture [ On ]
      •      
      •           Allow User Abort [ Off ]
      •      
      •           Freeze Window
      •      
      •           Commit Records/Requests [ Skip data entry validation; No dialog ]
      •      
      •           #Validate Dates
      •      
      •           If [ IsEmpty (PREF::gYear ) ]
      •      
      •           #Missing year
      •      
      •           Show Custom Dialog [ Title: "Warning"; Message: "Please select a year."; Default Button: “OK”, Commit: “Yes” ]
      •      
      •           Exit Script [ ]
      •      
      •           End If
      •      
      •           Close Window [ Name: "Sales by Item Detail"; Current file ]
      •      
      •           New Window [ Name: "Sales by Item Detail"; Height: 900; Width: 750; Top: 10; Left: 10; Style: Document; Close: “Yes”; Minimize: “Yes”; Maximize: “Yes”; Zoom Control Area: “Yes”; Resize: “Yes” ]
      •      
      •           Go to Layout [ “Graph Sales by Month pre 2012” (InvoiceHeadingJob) ]
      •      
      •           #Find by specified date range.
      •      
      •           Enter Find Mode [ ]
      •      
      •           Set Field [ InvoiceHeadingJob::graph_year; PREF::gYear ]
      •      
      •           New Record/Request
      •      
      •           Set Field [ InvoiceHeadingJob::graph_year; PREF::gYear2 ]
      •      
      •           Perform Find [ ]
      •      
      •           If [ Get (FoundCount) = 0 ]
      •      
      •           #No records found
      •      
      •           Close Window [ Current Window ]
      •      
      •           Refresh Window
      •      
      •           Show Custom Dialog [ Title: "Message"; Message: "No orders found within the specified date range."; Default Button: “OK”, Commit: “No” ]
      •      
      •           Exit Script [ ]
      •      
      •           End If
      •      
      •           Show/Hide Toolbars [ Show ]
      •      
      •           Print Setup [ Orientation: Portrait; Paper size: 8.26" x 11.69" ] [ Restore; No dialog ]
      •      
      •           Sort Records [ Keep records in sorted order; Specified Sort Order: InvoiceHeadingJob::Graph_Sort; ascending InvoiceHeadingJob::job_no; ascending ] [ Restore; No dialog ]
      •      
      •           View As [ View as Form ]
      •      
      •           Go to Record/Request/Page [ First ]
      •      
      •           Refresh Window
      •      
      •           Print Setup [ Orientation: Landscape; Paper size: 8.26" x 11.69" ] [ Restore; No dialog ]
      •      
      •           Enter Preview Mode
      •      
      •           Adjust Window [ Resize to Fit ]
      •      
      •           Go to Record/Request/Page [ Last ]
      •      
      •           Set Field [ PREF::gPageNumber; Get (PageNumber) ]
      •      
      •           Go to Record/Request/Page [ First ]
      •      
      •           Pause/Resume Script [ Indefinitely ]
      •      
      •           Enter Browse Mode
      •      
      •           Close Window [ Current Window ]