Subtraction instead of sum
Good evening
I need to subtract totals instead of sum them(see attachment).
I use following function to make the job
function Subtract(s:string):Variant;
var i : integer;
begin
result := 0;
for i := 0 to Measures.RecordCount - 1 do
begin
if Measures.detailValue(i,s) > 0 then
begin
if Measures.detailValue(i,'YearRec') = '2014' then
result := result + Measures.detailValue(i,s)
else
if Dimensions.IsTotalByRow and not Dimensions.IsTotalByCol then
result := result + Measures.detailValue(i,s)
else
result := result - Measures.detailValue(i,s);
end;
end;
end;
I call above function for each field like this
procedure Measure_1OnGetTotalValue(var Result: Variant);
begin
result := Subtract('Total Overnights');
end;
The problem is that is to slow.
Is there any recommendation?
The other problem is that I cannot find a solution to add another column, in totals, with percentage
Is there any solution fo this?
Many thnaks in advance
Nikos Andrianakis
I need to subtract totals instead of sum them(see attachment).
I use following function to make the job
function Subtract(s:string):Variant;
var i : integer;
begin
result := 0;
for i := 0 to Measures.RecordCount - 1 do
begin
if Measures.detailValue(i,s) > 0 then
begin
if Measures.detailValue(i,'YearRec') = '2014' then
result := result + Measures.detailValue(i,s)
else
if Dimensions.IsTotalByRow and not Dimensions.IsTotalByCol then
result := result + Measures.detailValue(i,s)
else
result := result - Measures.detailValue(i,s);
end;
end;
end;
I call above function for each field like this
procedure Measure_1OnGetTotalValue(var Result: Variant);
begin
result := Subtract('Total Overnights');
end;
The problem is that is to slow.
Is there any recommendation?
The other problem is that I cannot find a solution to add another column, in totals, with percentage
Is there any solution fo this?
Many thnaks in advance
Nikos Andrianakis
Comments
You can create simple measure based on filed 'Total Overnights' (with name 'to_Fantome') and hide it.
Then create calculation measure (with name 'TO'), set type 'calculation' and use script:
Also you can check v1 and v2 for assigned value:
(vartype(v1)<>0)
(vartype(v2)<>0)
Best regards,
Oleg Pryalkov.
For my second question(about percentage) is there any solution?