Generate Field Statistics

2 posts / 0 new
Last post
profit814
Offline
Joined: 03/18/2018 - 17:12
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's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

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