Skip to main content

Generate Field Statistics

I am writing a scipt to calcualte some ratios and am using the fieldstatistics funciton @FieldStatistics( "column 1 ",6 ). When i run the procedures as a script i am getting an error because field statistics have not been generated on the database prior to the calcualtions. Is there a command that i can use within idescript that will generate fieldstatistics?

Brian Element Mon, 04/16/2018 - 12:44

Yes there is, here is some example code that will check to see if the fields stats has been computed and if it hasn't then perform the computation.

 


Sub Main
	Set db = Client.OpenDatabase("Sample-Customers.IMD")
		
		' Get the field statistics.
		Set stats = db.FieldStats("CREDIT_LIM")
		
			' Determines whether the field statistics have been computed.
			If stats.Computed Then	
				MsgBox "The statistics are already computed." 
			Else 
				MsgBox "Computing the statistics." 
				stats.ComputeStats
			End If 
			
		' Clear the memory.
		Set stats = Nothing
	Set db = Nothing
End Sub