CalculateValue([Recursive: Boolean = True]);
CalculateValue(Recursive: boolean);
Recursive. The parameter that determines whether point is calculated recursively.
The CalculateValue method calculates point.
Available values of the Recursive parameter:
True. Default value. Point is calculated recursively.
False. Point is not calculated recursively.
Executing the example requires that the repository contains a regular report with the DOCUMENT identifier. The report contains a text sheet with a data area.
Add links to the Dimensions, Metabase, Report system assemblies.
Sub UserProc;
Var
MB: IMetabase;
MObj: IMetabaseObject;
Report: IPrxReport;
DIs: IPrxDataIslands;
DI: IPrxDataIsland;
DT: IPrxDataSource;
DTs: IPrxDataSources;
Points: IPrxCalculatedPoints;
Point, PointI: IPrxCalculatedPoint;
Style: IPrxCellStyle;
i, Count, Key, CountChildren: Integer;
Begin
MB := MetabaseClass.Active;
MObj := MB.ItemById("DOCUMENT").Edit;
Report := MObj As IPrxReport;
DIs := Report.DataIslands;
DI := DIs.Item(0);
DT := DI.Slice.Slices.DataSource;
DTs := DT.DataSources;
Points := DTs.Item(0).Points;
Points.Clear;
// First point:
Point := Points.Add;
Point.Name := "Point_1";
Style := Point.Style;
Style.IsDefault := True;
Point.CalculateValue;
// Second point:
Point := Points.Add;
Point.Name := "Point_2";
Style := Point.Style;
Style.IsDefault := True;
Point.CalculateValue;
// Third point:
Point := Points.Add;
Point.Name := "Point_3";
Style := Point.Style;
Style.IsDefault := True;
Point.CalculateValue;
// Output information:
Points.CalculateValues;
Count := Points.Count;
Debug.WriteLine("Number of calculated points: " + Count.ToString);
Debug.Indent;
Debug.WriteLine("# | Key | Name");
For i := 0 To Count - 1 Do
PointI := Points.Item(i);
Debug.WriteLine((i+1).ToString + " " + PointI.Key.ToString + " " + PointI.Name);
End For;
Debug.Unindent;
Debug.WriteLine("Information by the first calculated point");
PointI := Points.Item(0);
CountChildren := PointI.Children.Count;
Debug.Indent;
Debug.WriteLine("Point key: " + PointI.Key.ToString);
Debug.WriteLine("Unique point key: " + PointI.UniqueKey.ToString);
Debug.WriteLine("Key name: " + PointI.Name);
Debug.WriteLine("Data source: " + PointI.DataSource.Name);
Debug.WriteLine("Selection: " + PointI.SelectionSet.Item(0).Dimension.Name);
Debug.WriteLine("Number of child points: " + CountChildren.ToString);
Debug.WriteLine("Shift by dimension: " + PointI.IsShiftedPoint.ToString);
Debug.WriteLine("Value in point: " + PointI.Value);
Debug.WriteLine("Formatted value in point: " + PointI.FormattedValue);
Debug.Unindent;
// Remove point by index:
Points.Remove(0);
Debug.WriteLine("The point " + PointI.Name + " is removed with index: " + Key.ToString);
// Search and remove point by key:
Key := PointI.Key;
PointI := Points.FindByKey(Key);
Points.RemoveByKey(Key);
Debug.WriteLine("The point " + PointI.Name + " is removed with key: " + Key.ToString);
(Report As IMetabaseObject).Save;
End Sub UserProc;
After executing the example the console window displays:
Number of added calculated points.
Information about added calculated points: key and name.
Information about the first added point.
After that the point with the 0 index is removed, the point with the 0 key is found and removed.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Report;
…
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
MObj: IMetabaseObject;
Report: IPrxReport;
DIs: IPrxDataIslands;
DI: IPrxDataIsland;
DT: IPrxDataSource;
DTs: IPrxDataSources;
Points: IPrxCalculatedPoints;
Point, PointI: IPrxCalculatedPoint;
Style: IPrxCellStyle;
i, Count, CountChildren: Integer;
Key: uinteger;
Begin
MB := Params.Metabase;
MObj := MB.ItemById["DOCUMENT"].Edit();
Report := MObj As IPrxReport;
DIs := Report.DataIslands;
DI := DIs.Item[0];
DT := DI.Slice.Slices.DataSource;
DTs := DT.DataSources;
Points := DTs.Item[0].Points;
Points.Clear();
// First point:
Point := Points.Add();
Point.Name := "Point_1";
Style := Point.Style;
Style.IsDefault := True;
Point.CalculateValue(True);
// Second point:
Point := Points.Add();
Point.Name := "Point_2";
Style := Point.Style;
Style.IsDefault := True;
Point.CalculateValue(True);
// Third point:
Point := Points.Add();
Point.Name := "Point_3";
Style := Point.Style;
Style.IsDefault := True;
Point.CalculateValue(True);
// Output information:
Points.CalculateValues();
Count := Points.Count;
System.Diagnostics.Debug.WriteLine("Number of calculated points: " + Count.ToString());
System.Diagnostics.Debug.Indent();
System.Diagnostics.Debug.WriteLine("# | Key | Name");
For i := 0 To Count - 1 Do
PointI := Points.Item[i];
System.Diagnostics.Debug.WriteLine((i+1).ToString() + " " + PointI.Key.ToString() + " " + PointI.Name);
End For;
System.Diagnostics.Debug.Unindent();
System.Diagnostics.Debug.WriteLine("Information about the first calculated point");
PointI := Points.Item[0];
CountChildren := PointI.Children.Count;
System.Diagnostics.Debug.Indent();
System.Diagnostics.Debug.WriteLine("Point key: " + PointI.Key.ToString());
System.Diagnostics.Debug.WriteLine("Unique point key: " + PointI.UniqueKey.ToString());
System.Diagnostics.Debug.WriteLine("Point name: " + PointI.Name);
System.Diagnostics.Debug.WriteLine("Data source: " + PointI.DataSource.Name);
System.Diagnostics.Debug.WriteLine("Selection: " + PointI.SelectionSet.Item[0].Dimension.Name);
System.Diagnostics.Debug.WriteLine("Number of child points: " + CountChildren.ToString());
System.Diagnostics.Debug.WriteLine("Shift by dimension: " + PointI.IsShiftedPoint.ToString());
System.Diagnostics.Debug.WriteLine("Value in point: " + PointI.Value[True]);
System.Diagnostics.Debug.WriteLine("Formatted value in point: " + PointI.FormattedValue[True]);
System.Diagnostics.Debug.Unindent();
// Remove point by index:
Points.Remove(0);
System.Diagnostics.Debug.WriteLine("The point " + PointI.Name + " is removed with index: " + Key.ToString());
// Search and remove point by key:
Key := PointI.Key;
PointI := Points.FindByKey(Key);
Points.RemoveByKey(Key);
System.Diagnostics.Debug.WriteLine("The point " + PointI.Name + " is removed with key: " + Key.ToString());
(Report As IMetabaseObject).Save();
End Sub;
See also: