meaning of some parameters and their actual effect

Discussion forum for PivotCube VCL users. Common questions. Bug and problem reports

Moderator: Alex Zencovich

meaning of some parameters and their actual effect

Postby dophin » Tue Jul 03, 2007 2:55 pm

Hello, everybody

I'm trying to use a custom measure

I think that I need to sort the values
of a column of a Date rowdimension before
getting the sum of all the elements but the
first of another column.

I'd like to sort without changing the default
order during the calculus

I thought that I can use pivotGrid1.Map.SortRowDimension,
but I don't know the meaning of the second parameter and
whether the call of this procedure is enough to get the
column sorted

Could you please tell me the meaning
of that parameter and correct me if I'm wong ?

cheers

Joseph Osende
dophin
Developer
 
Posts: 33
Joined: Fri Jun 15, 2007 12:35 am

Postby AlexZencovich » Tue Jul 03, 2007 4:36 pm

1. it mean order of sorting - ascendin/descending
2. You should refresh grid after call (Grid.RefreshData)
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

Postby dophin » Tue Jul 03, 2007 5:17 pm

Thank you very much : I'll try it right now

.Joseph Osende
dophin
Developer
 
Posts: 33
Joined: Fri Jun 15, 2007 12:35 am

Postby dophin » Tue Jul 03, 2007 6:04 pm

Hello, Alex

I beg your pardon for writing once more on the same subject

I think that I still miss something

I'm doing the whole thing between a pdata = VarArrayLock(Data);
and VarArrayUnLock(Data);

Here is the chunk of code :

Value := 0;
lFound := false ;
pData := VarArrayLock(Data);
try

for I := 0 to pivotGrid1.Map.RowDimCount - 1 do
if pivotGrid1.Map.RowDimensions[ i ].AliasName = 'DATE' then
begin
lFound := true ;
break
end;
if ( lFound ) then
begin

pivotGrid1.Map.SortRowDimension( i, true );
pivotGrid1.RefreshData ;

if Count > 1 then
begin
for i := 1 to Count -1 do
BEGIN
;
Value := Value + pData[i];
end;
end
else
if ( count = 1 ) then
Value := pData[0]
end;
finally
VarArrayUnLock(Data);
end;

I'm trying to calculate the sum leaving alone the first valeur,
after sorting Ascending a Date column ?

The Date column is sorted, but I get a wrong value ...

Could you please tell me what's wrong ?

I also had a look at your example, and would like to ask you
why are you doing this :

Dec(Count,2 ) ?
dophin
Developer
 
Posts: 33
Joined: Fri Jun 15, 2007 12:35 am

Postby AlexZencovich » Tue Jul 03, 2007 6:16 pm

1. I have no idea how you fill variants array before it locked.

2. Please specify unit and line number. I have no idea where you find line of code you show.
There are lot of lines of code, sorry.
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

Postby dophin » Tue Jul 03, 2007 6:54 pm

Sorry.

Here are the details :

File : maindemo.pas
line N° : 1143
text : Dec(Count,2) ;

Best regards.

Joseph Osende
dophin
Developer
 
Posts: 33
Joined: Fri Jun 15, 2007 12:35 am

Postby AlexZencovich » Tue Jul 03, 2007 7:15 pm

There is calculation of "weighted" average. It remove min/max values from set and calculate simple average. Of course I should decrease count for 2 (min + max) before get average value.
Actually summa (value) calculated from 1 to Count - 2 in array 0..Count-1

Please note - in that event you cannot change sort order of dimensions!!! You may save required order somewhere else and change it after calculations done.
Otherwise you may jump in endless loop - you change order it call recalculation it change order etc...
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

Postby dophin » Tue Jul 03, 2007 7:28 pm

Thank you for the reply

Could you please tell me events when I can change the order
of a dimension, sort and then calculate ?

Best regards
dophin
Developer
 
Posts: 33
Joined: Fri Jun 15, 2007 12:35 am

Postby AlexZencovich » Tue Jul 03, 2007 8:08 pm

I do not know conditions of sort order change. But you may try TPivotMap.OnAfterRefresh.
You may also post custom Win message to your application. It will processed at least after core calculation performed.
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


Return to PivotCube VCL

Who is online

Users browsing this forum: No registered users and 4 guests

cron