Promotic
WikipediaLinkedInYoutubeTwitterFacebook

GetData - method of object PmTrend

Description:
Getting the stored data from the range specified by the vFilter parameter. According to the way of creating vFilter, either all data are returned or values are filtered if the filtration is used by AddFilter.

The method can return even a calculated value or the array of calculated values from the values of variables that meet the specified filter, see the assignment of the sWhat parameter.

Syntax:
GetData(sWhat As String, vFilter As Variant) As Array
Calling:
arr = oTrend.GetData(sWhat, vFilter)
Parameters:
sWhat(String) Specification of what to be returned:
 
It is possible to enter a list of variables whose value has to be returned.
- "a1;" or "a1;a2;a3;" - If an array of variables from the Data page has to be returned. It is necessary to keep the order of the variables from the page. For example, if, the order of variables on the page is a1,a2,a3,..., then in the parameter it is possible to enter, for example, "a1;a3;" but "a3;a1" is wrong.
- "time;" - If an array of the time has to be returned. Time setting can be changed by entering "time:winter;" and then all time values are returned in the "standard time" elsewhere they are in the "local time".
- "attr;" - If an array of the record attributes has to be returned.
- "*data;" - Mean all data variables except time and attribute ("time;*data;" returns time and all data variables).
- "*;" - Returns time, attribute and all data variables.
 
It is also possible to enter a function for calculation whose final value has to be returned. The functions can be concatenated by the ; char, for example "avg(a1);min(a1)". The following functions are supported:
- "avg(xx)" - The method returns the average value of the variable xx from the values that meet filtering conditions specified by the vFilter filter.
- "avg(xx;weighted)" - The method returns the weighed value of the variable xx from the values that meet filtering conditions specified by the vFilter filter. The weight of the value is here the length of its duration until the time of saving the next value.
- "min(xx)" - The method returns the minimum value of the variable xx from the values that meet filtering conditions specified by the vFilter filter.
- "max(xx)" - The method returns the maximum value of the variable xx from the values that meet filtering conditions specified by the vFilter filter.
- "sum(xx)" - The method returns the sum of all values of the variable xx from the values that meet filtering conditions specified by the vFilter filter.
- "count(xx)" - The method returns the number of values of the variable xx from the values that meet filtering conditions specified by the vFilter filter.
 
It is possible to enter only the list of variables or function for calculation - but not at the same time. For example, "avg(0);a1" is WRONG.
vFilter(Variant) Value that defines, for example, the time Range of the got data (time from, time to, number of points, etc.), possible if the data have to be filtered by the value. It is created by calling the CreateFilter, AddFilter methods.
 
The value filter (filter for each value added by AddFilter method) will be applied following way:

If the sWhat parameter contains the list of variables, then it could happen that for each variable there would be a different number of lines (different number of stored values). Therefore it is necessary to process "lines intersection" - i.e. select only lines common for all variables.

If the sWhat parameter contains the calculation functions, then the value filters for each variable will be used only for calculating these variables and will not affect calcualtion of another variables.

Return Values:
Returns requested data as 1- or 2-dimensional array of values or it returns Empty if such data don't exist or if an error occurred.

If in sWhat is function for calculation than it returns either the simple value or the 1-dim array of calculated values.

Note:
Statistical operations over the data field can also be done by the Pm.ArrayOper method.
Example:
See examples in the CreateFilter and AddFilter methods
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice