SelectionComparatorData: IValidationSelectionValueList;
The SelectionComparatorData property returns a set of selections determining data used for comparison.
To set compared series, use the IValidationDetails.SelectionFilter property.
If ComparatorData is not set, data for comparison is determined from the IValidationDetails.SelectionTargetData value.
Executing the example requires that the repository contains a time series database with the TSDB_TARGET identifier containing a validation rule with the VALIDATION identifier. The specified time series database should contain custom attribute with the CITY identifier. The repository should also contain a time series database with the TSDB identifier with the structure identical to the TSDB_TARGET structure.
Add links to the Cubes, Dimensions, Metabase, Ms, Rds system assemblies.
Sub UserProc;
Var
Mb: IMetabase;
RubrObj: IMetabaseObjectDescriptor;
ValidObj: IMetabaseObject;
ValidFilter: IValidationFilter;
Ratio: IValidationRatio;
ComparisonValue: IValidationComparisonValue;
SelectionValList: IValidationSelectionValueList;
Rub: IRubricator;
SelectionFilter: IValidationSelectionFilter;
FilterVals: IValidationSelectionValues;
MetaAttr: IMetaAttribute;
SelectionVal: IValidationSelectionValue;
DimInst: IDimInstance;
DimSel: IDimSelection;
Begin
Mb := MetabaseClass.Active;
// Get compared time series database
RubrObj := Mb.ItemById("TSDB_TARGET");
Rub := RubrObj.Bind As IRubricator;
// Get validation rule
ValidObj := Mb.ItemByIdNamespace("VALIDATION", RubrObj.Key).Edit;
ValidFilter := ValidObj As IValidationFilter;
// Set calendar frequency of checked data
ValidFilter.Level := DimCalendarLevel.Year;
// Set validation rule type
ValidFilter.Kind := ValidationDetailsKind.Ratio;
// Get parameters of the Compare Observations Relations validation
Ratio := ValidFilter.Details As IValidationRatio;
// Set comparison parameters
ComparisonValue := Ratio.ComparisonValue;
ComparisonValue.ComparisonOperator := ValidationComparisonOperator.Less;
ComparisonValue.Percentage := False;
ComparisonValue.Value1 := 0.3;
// Set compared data
SelectionFilter := Ratio.SelectionFilter;
SelectionFilter.Clear;
MetaAttr := Rub.Facts.Attributes.FindById("CITY");
DimInst := MetaAttr.ValuesObject.Open(Null) As IDimInstance;
DimSel := DimInst.CreateSelection;
FilterVals := SelectionFilter.Add(DimSel);
DimSel.SelectElement(1, False);
FilterVals.Selection := DimSel;
// Specify time series database used for comparison
RubrObj := Mb.ItemById("TSDB");
Ratio.Comparator := RubrObj.Bind As IVariableStub;
// Set data used for comparison
SelectionValList := Ratio.SelectionComparatorData;
SelectionValList.Clear;
Rub := RubrObj.Bind As IRubricator;
MetaAttr := Rub.Facts.Attributes.FindById("CITY");
DimInst := MetaAttr.ValuesObject.Open(Null) As IDimInstance;
DimSel := DimInst.CreateSelection;
SelectionVal := SelectionValList.Add(DimSel);
DimSel.DeselectAll;
DimSel.SelectElement(1, False);
SelectionVal.Value := DimSel.ToVariant;
// Clear validation execution area
Ratio.SelectionTargetData.Clear;
// Save the rule
ValidObj.Save;
End Sub UserProc;
After executing the example the Compare Observations Relations validation rule is set. Relations of observations between the TSDB_TARGET and TSDB databases are compared.
See also: