Hi,
How i repeat dimensionindex[3] at TPVRowToolbar in run time ?
Moderator: Alex Zencovich
procedure TForm1.ABCanalysis1Click(Sender: TObject);
var
i : integer;
d : TMapDimension;
a,b,c,item : TMapDImensionItem;
total,f,avg : double;
begin
Removeanalysisitems1Click(Sender);
d := nil;
for I := 0 to PivotMap1.DimensionCount - 1 do
if PivotMap1.Dimensions[i].AliasName = 'Ware' then
begin
d := PivotMap1.Dimensions[i];
Break;
end;
if d = nil then
Exit;
total := PivotMap1.Total[0,mvtValue];
avg := total/d.Count;
a := TMapDimensionItem.Create;
a.ID := $FFFFFA;
a.Key := $FFFFFA;
a.Name := 'A';
a.Dimension := d;
a.Description := '20% items which produce near 70% profit';
a.State := disActive;
a.isGroup := True;
a.isCustomGroup := True;
a.ExpandedToNextLevel := True;
b := TMapDimensionItem.Create;
b.ID := $FFFFFB;
b.Key := $FFFFFB;
b.Name := 'B';
b.Description := '30% items which produce near 20% profit';
b.Dimension := d;
b.State := disActive;
b.isGroup := True;
b.isCustomGroup := True;
b.ExpandedToNextLevel := True;
c := TMapDimensionItem.Create;
c.ID := $FFFFFC;
c.Key := $FFFFFC;
c.Name := 'C';
c.Description := '50% items which produce near 10% profit';
c.Dimension := d;
c.State := disActive;
c.isGroup := True;
c.isCustomGroup := True;
c.ExpandedToNextLevel := True;
for i := d.Count - 1 downto 0 do
begin
item := d.Items[i];
PivotCube1.Intf._GetItemValue(PivotMap1,d.FIndex,item.ID,0,f);
d.DeleteItem(item);
if f / avg > 4 then
a.AddItem(item)
else
if f / avg > 0.5 then
b.AddItem(item)
else
c.AddItem(item);
end;
d.AddItem(a);
d.AddItem(b);
d.AddItem(c);
d.DefaultSort := ddsSortByNameA; // force resort!
PivotMap1.RefreshData(True);
Windows.MessageBox(0,PChar('Dimension Ware structure was changed, so now you will see 3 separate groups (A,B,C) which was created by overall sales volume by each Ware item. Please note: Current dimension filters will used in group membership calculation!'),PChar('ABC-analysis info'),MB_OK+MB_ICONINFORMATION);
end;
Users browsing this forum: No registered users and 3 guests