Repeat Dimension

Useful shares from PivotCube VCL - code example, algorithm solutions etc

Moderator: Alex Zencovich

Repeat Dimension

Postby José Luiz » Sun Nov 30, 2008 8:51 pm

Hi,

How i repeat dimensionindex[3] at TPVRowToolbar in run time ?
José Luiz
User
 
Posts: 15
Joined: Wed Nov 26, 2008 8:52 pm

Re: Repeat Dimension

Postby AlexZencovich » Mon Dec 01, 2008 5:37 am

Repeat? Each dimension is unique entity so you cannot duplicate it.
Best regards,

Alex Zencovich
-------------------------------------------------------------------------------------------------------------------------------------------
www.pivotcube.com - OLAP solution for Delphi, C++ Builder and ActiveX environment
AlexZencovich
Site Admin
 
Posts: 580
Joined: Sun Jun 18, 2006 10:09 am

Re: Repeat Dimension

Postby José Luiz » Mon Dec 01, 2008 6:05 pm

okay..

look this:

var
ABC, d : TMapDimension;
a,b,c,item : TMapDImensionItem;

for i := 0 to Mapa.DimensionCount - 1 do
Begin
if Mapa.Dimensions[i].AliasName = 'Ware' then
begin
d := Mapa.Dimensions[i];
break;
end;
end;

abc := d;

how can i do to insert at (TpivotMap) and insert at (TpvToolar) the Dimension abc ?


Best regards
José Luiz
User
 
Posts: 15
Joined: Wed Nov 26, 2008 8:52 pm

Re: Repeat Dimension

Postby AlexZencovich » Mon Dec 01, 2008 7:22 pm

Look at
procedure TPivotMap.DimensionToRow(const DimensionName: WideString;
at: TMapPosition; Position: Integer);

where at : TMapPosition = TOleEnum;
const
maSingle = $00000000;
maTop = $00000001;
maBottom = $00000002;
maPosition = $00000003;


Atrer all changes made, call TPivotMap.RefreshData(True) to apply changes to toolbars
Best regards,

Alex Zencovich
-------------------------------------------------------------------------------------------------------------------------------------------
www.pivotcube.com - OLAP solution for Delphi, C++ Builder and ActiveX environment
AlexZencovich
Site Admin
 
Posts: 580
Joined: Sun Jun 18, 2006 10:09 am

Re: Repeat Dimension

Postby José Luiz » Mon Dec 01, 2008 7:35 pm

Sorry,

I need insert this procedure ?

procedure TPivotMap.DimensionToRow(const DimensionName: WideString;
at: TMapPosition; Position: Integer);

const
maSingle = $00000000;
maTop = $00000001;
maBottom = $00000002;
maPosition = $00000003;
José Luiz
User
 
Posts: 15
Joined: Wed Nov 26, 2008 8:52 pm

Re: Repeat Dimension

Postby AlexZencovich » Tue Dec 02, 2008 6:31 am

No, you have to use it when you would like to put specifed dimension to row side or column side (DimensionToColumn procedure)
Best regards,

Alex Zencovich
-------------------------------------------------------------------------------------------------------------------------------------------
www.pivotcube.com - OLAP solution for Delphi, C++ Builder and ActiveX environment
AlexZencovich
Site Admin
 
Posts: 580
Joined: Sun Jun 18, 2006 10:09 am

Re: Repeat Dimension

Postby José Luiz » Tue Dec 02, 2008 10:45 am

Actually my need is that the sample code in the demo on ABC Analysis see what I wanted to change in code and I can not find any solution.

This Line :
d.DeleteItem(item);
I did not want to delete the item, but included in another dimension, or include deleting what I'm in another dimension
because this way I do not have the size and the most I can lose it.
Yesterday I was until 03:00 am to try to find a solution and not succeeded. ahuhauhuauah


Code: Select all
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;
José Luiz
User
 
Posts: 15
Joined: Wed Nov 26, 2008 8:52 pm

Re: Repeat Dimension

Postby José Luiz » Tue Dec 02, 2008 3:02 pm

Its a impossible ?
José Luiz
User
 
Posts: 15
Joined: Wed Nov 26, 2008 8:52 pm

Re: Repeat Dimension

Postby AlexZencovich » Wed Dec 03, 2008 5:05 pm

Yes. It is impossible. You cannot remove item from one dimension and put it to another - like get entry from Ware and put it to Clients (if I understand right)
Best regards,

Alex Zencovich
-------------------------------------------------------------------------------------------------------------------------------------------
www.pivotcube.com - OLAP solution for Delphi, C++ Builder and ActiveX environment
AlexZencovich
Site Admin
 
Posts: 580
Joined: Sun Jun 18, 2006 10:09 am

Re: Repeat Dimension

Postby José Luiz » Mon Dec 08, 2008 3:00 pm

Yes, it's work now....

Tanks.
José Luiz
User
 
Posts: 15
Joined: Wed Nov 26, 2008 8:52 pm


Return to PivotCube VCL

Who is online

Users browsing this forum: No registered users and 3 guests

cron