on 08-11-2020 8:12 AM
Hi,
I've requirement to create a cross-tab in report. But the problem is I don't know how to do calculation for both of this column in crosstab:
1. Open 30%
Formula: Total Open Status per Assignee / Grand Total * 100
Example (Michael) : 10/ 28 * 100 = 35.71%
2. % permonth
Formula: Grand Total for all status per Assignee / Grand Total for Status * 100
Example (Michael) : 11/ 28 * 100 = 39.29 %
I've encounter an error 'Argument #2 of 'GridValueAt' is out of range' using below code :
if GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("OPEN"), CurrentSummaryIndex)=0 then 0 else GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("OPEN"), CurrentSummaryIndex)/ GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("Total"), CurrentSummaryIndex) * 100
Could someone teach me how to do the calculation and provide me with some sort of suggestion/solution to this issue?
Thank you.
Replace Line#21 with:
If GridRowColumnValue("table.DOC_DATE", i) = s then
Regarding formula#2, does your crosstab have a field under "Columns" like in the attached screenshot:
If yes, then this is the field you need to use in the formula.
If you don't have a column then where are the status values being generated from?
-Abhilash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Athi,
Not sure why you have the "for loop" at two places set to:
for i := 0 to getRowPathIndexof (s) - 0 do
It should be:
for i := 0 to getRowPathIndexof (s) - 1 do
For the second formula, have you surrounded the formula name in double-quotes, like so:
GetTotalValueFor("@FX_CRStatus");
-Abhilash
I'm sorry, Line# 4 should be:
local dateTimevar s := GridRowColumnValue("table.DOC_DATE", CurrentRowIndex);
In Formula #2, you cannot use "AssignedID" as that's the "summary" field and not the "column" field of the crosstab. You need to use the field that shows values: closed, open, rejected.
-Abhilash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Formula 1:
Got same error but this time error in line#21 as red highlighted. It is we have to convert datetime to string?
Formula 2:
I've tried all the value (open/rejected/closed) you suggested but it's seems not working. For this column, I want to get the total percentage per assignee.
For example,
(Total (closed+open+rejected) per assignee / grand total of status for all assignee) * 100
Thanks
Try this please:
1. Replace Line#4 in the first formula to :
local stringvar s := GridRowColumnValue("table.DOC_DATE", CurrentRowIndex);
2. In formula#2, you need to replace "GRAND TOTAL" with the actual database column that is used as the crosstab's column.
-Abhilash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Athi,
Assuming you've already inserted the two calculation columns, here's what you need to do:
1. Right-click one of the summary cells under the "Open 30%" column > Calculated Member > Edit Calculation formula > Use this code:
local numbervar i;
local numbervar j;
local numberVar ctot;
local stringvar s := gridlabelat("Month field", CurrentRowIndex); //Replace "Month field" with the field you've used as the Row. Surround the field with double quotes and not the default curly braces - { }
local numberVar rtot := gridvalueat(CurrentRowIndex, GetColumnPathIndexOf("OPEN"), CurrentSummaryIndex);
If CurrentRowIndex = 0 then
(
for i := 0 to getRowPathIndexof(s)-1 do
(
for j := 0 to CurrentColumnIndex-1 do
(
ctot := ctot + gridValueAt(i, j, CurrentSummaryIndex);
);
);
IF ctot = 0 then 0 Else rtot % ctot;
)
Else
(
for i := 0 to getRowPathIndexof(s)-1 do
(
If gridlabelat("Month field", i) = s then
(
for j := 0 to CurrentColumnIndex-1 do
(
ctot := ctot + gridValueAt(i, j, CurrentSummaryIndex);
);
);
);
IF ctot = 0 then 0 Else rtot % ctot;
);
2. Right-click one of the summary cells under the "% per month" column > Calculated Member > Edit Calculation formula > Use this code:
local numbervar i;
local numbervar j;
local numberVar ctot;
local stringvar s := gridlabelat("Month field", CurrentRowIndex); //Replace "Month field" with the field you've used as the Row. Surround the field with double quotes and not the default curly braces - { }
local numberVar rtot := GetTotalValueFor("Field Used as crosstab's column"); //Replace "Field Used as crosstab's column" with the field you've used for the Column. Surround the field with double quotes and not the default curly braces - { }
If CurrentRowIndex = 0 then
(
for i := 0 to getRowPathIndexof(s)-1 do
(
for j := 0 to CurrentColumnIndex-1 do
(
ctot := ctot + gridValueAt(i, j, CurrentSummaryIndex);
);
);
IF ctot = 0 then 0 Else rtot % ctot;
)
Else
(
for i := 0 to getRowPathIndexof(s)-1 do
(
If gridlabelat("Month field", i) = s then
(
for j := 0 to CurrentColumnIndex-1 do
(
ctot := ctot + gridValueAt(i, j, CurrentSummaryIndex);
);
);
);
IF ctot = 0 then 0 Else rtot % ctot;
);
-Abhilash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Could you see the attachments? I've encounter error for both script you have provided.
Error 1: A date-time required here.
My date format: 28/8/2020 12:00:00 AM
Error 2: This is not the name of a grid group for the field being formatted.
Thanks.
My applogize. I can't share the .rpt file, my workplace didn't allow to share it since it's the data is confidential. I hope you can understand.
Btw, I tried to attached screenshot in previous comment.
Thanks
Hi,
Could please anyone help me to solve this problem?
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.