RUNNING TOTAL
Hi,
Can any one tell me how to create a running total in Oracle reports. I have two fields pulled in the SQL called CR and DR. I want to do the running total at report level. Here what I want
CR------DR-------RTOTAL
20-----10---------10 ( here the RTOTAL Field is (20 - 10) )
30-----15---------25 ( here the RTOTAL Field is (30 - 15) + 10)
50-----25---------50 ( here the RTOTAL Field is (50 - 25) + 25)
75-----35---------90 ( here the RTOTAL Field is (75 - 35) + 50)
Thanks
-Feroz
Hi Bernd ,
I tried this and here is the result.
Query :
SELECT MAIN_AC_CODE, JV_NO_T, JV_DATE_T, JV_DR_AMT, JV_CR_AMT, SUM(JV_DR_AMT - JV_CR_AMT) OVER ( PARTITION BY MAIN_AC_CODE ORDER BY MAIN_AC_CODE,JV_NO_T) RUNNING_TOTAL
FROM FIN_JV_T WHERE MAIN_AC_CODE = 1102071001
ORDER BY MAIN_AC_CODE, JV_NO_T , JV_DATE_T
output :
MAIN_AC_CODE JV_NO JV_DATE DR_AMT CR_AMT RUNNING_TOTAL
1102071001 JV1 05-JUL-06 6000 0 -11650
1102071001 JV1 05-JUL-06 0 17650 -11650
1102071001 JV13 15-JUL-06 15000 0 12750
1102071001 JV13 15-JUL-06 30000 0 12750
1102071001 JV13 15-JUL-06 7000 0 12750
1102071001 JV13 15-JUL-06 0 30200 12750
1102071001 JV13 15-JUL-06 1500 0 12750
1102071001 JV13 15-JUL-06 1100 0 12750
1102071001 JV14 16-JUL-06 1100 0 16358
1102071001 JV14 16-JUL-06 2508 0 16358
1102071001 JV15 16-JUL-06 3609 0 19872
1102071001 JV15 16-JUL-06 0 95 19872
1102071001 JV16 16-JUL-06 0 3608 16264
1102071001 JV19 17-JUL-06 17000 0 -6668
1102071001 JV19 17-JUL-06 0 22932 -6668
1102071001 JV2 05-JUL-06 84000 0 18213
1102071001 JV2 05-JUL-06 0 59119 18213
1102071001 JV20 17-JUL-06 0 13000 5213
1102071001 JV21 17-JUL-06 0 4000 1213
1102071001 JV4 05-JUL-06 28134 0 -31786.57
1102071001 JV4 05-JUL-06 0 61133.57 -31786.57
1102071001 JV5 05-JUL-06 0 2970 -34756.57
1102071001 JV7 05-JUL-06 5500 0 -29256.57
1102071001 JV8 09-JUL-06 12500 0 -39147.57
1102071001 JV8 09-JUL-06 0 22391 -39147.57
1102071001 JV9 12-JUL-06 6740 0 -45107.57
1102071001 JV9 12-JUL-06 0 12700 -45107.57
Similar Messages
-
Item Transaction History Report - Calculation for creating 'Running Total'
Hello
Using Oracle Discoverer, we have written a report that pulls back all Inventory Transactions (by item number). This report lists both transactions IN (e.g. receipts into the store) and OUT (e.g. issues out from the store).
Our customer would like an additional column, to represent 'Running Total', to be added to the report. This column needs to capture the running 'On Hand Quantity' for the associated Item, as each transaction (both transactions IN and OUT of store) is displayed.
For example, if the initial/first transaction for an item was a Receipt of 500, then this column (on the first line) should display 500. If the second transaction for the item was an issue of 15, then this column (on the second line) should display 485. If the third transaction was for an issue of 50, then this column (on the third line) should display 435. If the fourth transaction was for a receipt of 20, then this column (on the fourth line) should display 455 etc etc
I'm not sure how I'd write a calculation to cater for this (within discoverer) - do you know if this is achievable? Any help would be much appreciated. This would be easy enough to do in Excel, but I'm a bit of a novice when it comes to discoverer(!)
Many thanks
RossHi,
You can generally do this type of calculation using analytic functions. You would partition by the item number and order by the transaction date in the analytic function. You can use SUM function (with an order by) to get a running total of a column in the report. You can SUM a calculation containing a CASE statement which changes the OUT transactions to a negative number. The SUM function will start at zero, so you then can use FIRST_VALUE function to get the first value for the item which you could then add to the totals.
Rod West -
Showing running totals on AR statatement Report
Hi All I need assistance in populating the Running totals on AR statement Report , I am trying to calculate the running total on the RDF using the (sum Over Partition ) and Not on the RTF template please assist .
here is my query below :
select customers.customer_name,
detail.customer_id,
detail.customer_site_use_id,
:CP_ACC_NAME,
:CP_ACC_NUM,
:CP_BRNCH_NAME,
:CP_COL_EMAIL,
:CP_COL_PHONE,
:CP_BRANCH_NR,
decode( (select meaning
from ar_lookups
where lookup_type = 'INV/CM/ADJ' and lookup_code = detail.class), 'Payment', apply_date, trx.trx_date) TRX_DATE,
trx.INVOICE_CURRENCY_CODE,
trx.INVOICE_CURRENCY_CODE INVOICE_CURRENCY_CODE_BAL,
NVL(trx.term_due_date,trx.TRX_DATE) term_due_date,
detail.customer_id cst_id,
detail.customer_site_use_id cst_site_id,
detail.customer_trx_id,
detail.trx_number,
(select meaning
from ar_lookups
where lookup_type = 'INV/CM/ADJ' and lookup_code = detail.class) class,
detail.amount_full_original,
detail.end_bal * -1 , (detail.end_bal + detail.amount_full_original)* -1 closing_balance ,
detail.amount_full_original - detail.the_order * -1 closing_bal,
(detail.amount_full_original - detail.running_total) running_total ,
detail.running_tot ,
customers.customer_name address1,
customers.address1 address2,
customers.address2 address3,
customers.address3 address4,
customers.city||' '||customers.state address5,
customers.country||' '||customers.postal_code address6,
addr.address1 rm_address1,
addr.address2 rm_address2,
addr.address3 rm_address3,
addr.address4 rm_address4,
addr.address5 rm_address4,
:p_as_of_date_from date_from,
to_char(to_date(:p_as_of_date_to,'DD-MON-YYYY'),'DD-Mon-YYYY') date_to,
addr.org_id rm_org_id,
rtrim(to_char(sysdate,'DD')||' '||to_char(sysdate,'Month'))||' '||to_char(sysdate, 'YYYY') curr_date
from (select customer_id, CUSTOMER_SITE_USE_ID, trx.CUSTOMER_TRX_ID,trx.TRX_NUMBER, null apply_date,ps.class,ps.AMOUNT_DUE_ORIGINAL amount_full_original, the_trx.end_bal,the_trx.running_total , the_trx.running_tot , 1 the_order
select customer_trx_id, sum(acctd_end_bal) end_bal , running_total , running_tot
SELECT ps.customer_trx_id ,
sum(ar_calc_aging.begin_or_end_bal(ps.gl_date,ps.gl_date_closed,
NULL,to_date(:p_as_of_date_from))
* ps.amount_due_remaining) start_bal,
sum(ar_calc_aging.begin_or_end_bal(ps.gl_date,ps.gl_date_closed,
NULL,to_date(:p_as_of_date_to))
* ps.amount_due_remaining) end_bal,
sum(ar_calc_aging.begin_or_end_bal(ps.gl_date,ps.gl_date_closed,
NULL,to_date(:p_as_of_date_from))
* ps.acctd_amount_due_remaining) acctd_start_bal,
sum(ar_calc_aging.begin_or_end_bal(ps.gl_date,ps.gl_date_closed,
NULL,to_date(:p_as_of_date_to))
* ps.acctd_amount_due_remaining) acctd_end_bal ,
(sum(ar_calc_aging.begin_or_end_bal(ps.gl_date,ps.gl_date_closed,
NULL,to_date(:p_as_of_date_from))
* ps.amount_due_remaining) + sum(ar_calc_aging.begin_or_end_bal(ps.gl_date,ps.gl_date_closed,
NULL,to_date(:p_as_of_date_to))
* ps.acctd_amount_due_remaining) ) running_total ,
sum((sum(ar_calc_aging.begin_or_end_bal(ps.gl_date,ps.gl_date_closed,
NULL,to_date(:p_as_of_date_from))
* ps.amount_due_remaining) + sum(ar_calc_aging.begin_or_end_bal(ps.gl_date,ps.gl_date_closed,
NULL,to_date(:p_as_of_date_to))
* ps.acctd_amount_due_remaining) )) over (partition by ps.customer_trx_id order by ps.customer_trx_id)running_tot
FROM ar_payment_schedules_all ps
WHERE ps.payment_schedule_id+0 > 0
--JF2 AND ps.gl_date_closed >= to_date(:p_as_of_date_from)
AND ps.class IN ( 'CB', 'CM','DEP','DM','GUAR','INV')
AND ps.gl_date <= to_date(:p_as_of_date_to)
and org_id = nvl(:P_ORG_ID,org_id)--1246
--and customer_id = :p_customer_id --1075
--and CUSTOMER_SITE_USE_ID = :p_customer_site_id --1066
--and customer_trx_id = 66291
--'|| l_ps_org_where ||'
GROUP BY ps.customer_trx_id ,ps.acctd_amount_due_remaining , ps.gl_date,ps.gl_date_closed ,ps.class , rownum
ps.customer_trx_id ,
sum(ar_calc_aging.begin_or_end_bal(ps.gl_date,ps.gl_date_closed,
ra.gl_date,to_date(:p_as_of_date_from))
* ( ra.amount_applied + NVL(ra.earned_discount_taken,0)
+ NVL(ra.unearned_discount_taken,0))) start_bal,
sum(ar_calc_aging.begin_or_end_bal(ps.gl_date,ps.gl_date_closed,
ra.gl_date,to_date(:p_as_of_date_to))
* ( ra.amount_applied + NVL(ra.earned_discount_taken,0)
+ NVL(ra.unearned_discount_takenHi
Yes i would like more help as i have never used group by roll up before
SELECT p.employee_number,
p.full_name employee_name,
DECODE (p.sex, 'M', 'Male', 'F', 'Female') gender,
(DECODE (p.per_information4,
'01', 'Indian',
'02', 'African',
'03', 'Coloured',
'04', 'White')) race,
p.original_date_of_hire,
a.effective_start_date startdate_current_position,
RTRIM (SUBSTR (ps.NAME, 1, INSTR (ps.NAME, ';')), ';') current_position,
ho.NAME current_organization,
xx_return_company_name(a.person_id, a.effective_start_date) current_company,
RTRIM (SUBSTR (ps1.NAME, 1, INSTR (ps1.NAME, ';')),';') previous_position,
ho1.NAME previous_organization,
xx_return_company_name(a1.person_id, a1.effective_start_date) previous_company,
a1.effective_start_date startdate_prev_position
FROM per_assignments_v2 a,
per_assignments_v2 a1,
per_all_people_f p,
per_all_positions ps,
per_all_positions ps1,
hr_all_organization_units_tl ho,
hr_all_organization_units_tl ho1
WHERE a1.person_id = a.person_id
AND NVL (a1.position_id, 9) <> a.position_id
AND a1.effective_end_date = a.effective_start_date - 1
AND p.person_id = a.person_id
and ho.ORGANIZATION_ID=ps.ORGANIZATION_ID
and ho1.ORGANIZATION_ID=a1.ORGANIZATION_ID
AND a.effective_start_date BETWEEN p.effective_start_date AND p.effective_end_date
AND a.position_id = ps.position_id
and p.EMPLOYEE_NUMBER not in ('1','2','3')
AND a1.position_id = ps1.position_id(+)
order by p.full_name -
XML 5.6.1 Running Total
Hi
I am new this XML Publisher. We are working on using BPA/XML Publisher to print the AR Invoice. I have two questions
1. How to print the values of subtotal, tax and Invoice Total in only last page
2. How to print the Running total of extend amount at the end of the each page. This Running total need to be printted once in a Page.
Thanks
MariappanHave you placed it outside your group, you just place it at the bottom end of your template and put a group around your sum total.
Then it it will only be printed on your last page.
you need a for tag
ex. <?for-eachG_TAX?>
Then the sum
ex. <?sum(current-group()//VAT)?>
Then the end tag
ex. <?end for-each?> -
Running total in report footer returning inaccurate result
Post Author: smarkta
CA Forum: Formula
I am writing a report that contains 3 groups. I have created running totals for each group that are accurate by selecting the group to evaluate and reset on. now I need to basically sum the results of the all the group running totals but have had no success. any tips on how to do this would be greatly appreciated.
ThanksPost Author: Charliy
CA Forum: Formula
Were you doing a Distinct Count? Did you have a formula on the Running Total? What is there about the Group Totals that make them different than the final total. -
How do I use a running total within a selection formula?
I am developing a report within Crystal Reports 2008. My goal is to identify any accounts that have zero usage for at least six months in this current year. I have account number, meter size, read date, usage, and a running total/subtotal by account.
Here is what the data looks like in the report
ACCTNO METER SIZE READ DATE/TIME READ_USAGE Counter
001022-05
001022-05 2.00 9/28/2009 9:42:00 AM 0.00 1
1
001110-09
001110-09 2.00 3/2/2009 9:54:13 AM 0.00 1
001110-09 2.00 3/26/2009 1:32:28 PM 0.00 1
001110-09 2.00 4/27/2009 11:02:11 AM 0.00 1
001110-09 2.00 5/27/2009 1:13:53 PM 0.00 1
001110-09 2.00 6/19/2009 11:41:20 AM 0.00 1
001110-09 2.00 9/1/2009 8:13:25 AM 0.00 1
6
My report shows all accounts that have zero usage. I want to filter the report to only show the accounts that have at least six zero usage reads. I thought I could add a running total, sum it, and filter the data by using the selection formulas. Unfortunately I keep getting an error message saying "this field cannot be used becuase it is being evaluated later." Any help would be appreciated. This is the first report I have created using crystal.
Edited by: smwdrw2 on Oct 28, 2009 4:29 PMYou could Conditionally suppress the account numbers where your running total is less than 6
You will probably have to put your account number summaries in the group footer, instead of the header.
Then:
go to the section expert, click on the group footer for the account number, on the right, next to the word "Suppress" click on the box that says "X-2". In the formula put
IF<6 then True
Save and close
The only way this would not work for you is if you have some sort of grand total that you don't want to include the other groups in. -
How can I display the vendor associated with result of my running total sum
I have a report that lists vendors with their most vecent order dates. I need to set up a rotation so that the vendor with the latest order date is next to be selected. I used the running total summary to pick the latest date. How can I display the vendor associated with result of my running total summary?
If your "latest" order date means the "oldest" order date, why don't you try this:
Go to Report tab -> Record Sort Expert -> Choose your order date in ascending order
This will make your oldest order your first record shown.
You can then create a running total count for each record.
Lastly, in your section expert under conditional suppress X+2 formula, write this:
{#CountRecords}>1
The result will only show the oldest record in your report.
I hope that helps,
Zack H. -
Running Total - How to summarize a formula field?
I'm sorry if this comes over as stupid but I have got myself quite messed up and am not 100% au fait with Crystal Reporting.
The aim of my report is to calculate the costs of selected tests and to calculate a grand total of all tests at the end.
I have created a group of jobtests.TestTypeName
Details
1. testTypeName - to show Test Name that is being calcutaed - Database field
2. Count ({jobTests.testTypeName}, {jobTests.testTypeName}) - to show number of tests of that type - this is a formula field
3. Analysis1 - to show the cost of that test type - Database field
4. {@CountTests/TestType} * {jobTests.AnalysisN1} - to show the number of tests per test type mulitplied by the cost of that test type - this is a formula field
Report footer
Count ({jobTests.testTypeName}) - to count the total number of tests
MY PROBLEM - I need to see the sum of 4, this would be my grand total
Trying to run the Running Total I can't get it to Summarize the field 4 because it is a formula field.
What can I do?
Thanks.You can't do a SUM on a formula that uses another aggregate function. However, for both 4 and your grand total, you just need to SUM() (with ",{jobTests.testTypeName}" for the #4 calc), as the database field will be the cost for each test in each record.
HTH,
Carl -
Error when using running total variable in formula
This is probably an easy syntax problem, but I'm fairly new to Crystal reporting. I created a running total variable (count) called InquiryTypeSubtotal that simply counts the number of records. I have one grouping level, and in the group footer I'd like to print a line showing the total count for that group that looks like
Total inquiries for Assistive Technology: 3
To accomplish this I'm using a formula field with the following syntax:
"Total inquiries for " + {CnAttrCat_1.CnAttrCat_1_Description} + ": " + ToText(@InquiryTypeSubtotal)
When I try to check the formula, I get the error message "The ) is missing." What am I doing wrong?
Thanks,
AlecI put in the curly brackets so my formula now reads
"Total inquiries for " + {CnAttrCat_1.CnAttrCat_1_Description} + ": " + ToText({@InquiryTypeSubtotal})
Now when I check the formula I get the error message "This field name is not known."
Alec -
Running totals: Custom Reset via Formula? (VS 2005)
Post Author: PunchngMrGrumpy
CA Forum: .NET
Hi All,I have attached a screenshot to help make up for my inability to describe the situation I'm dealing with here.I
have three groups within a report that currently use distinct Running
Totals fields that Reset at the group levels that I assigned. I am
attempting to create a single Running Totals field for all 3 groups
that will reset depending on which Group is being calculated at the
moment so that I don't have to have 3 separate Running Totals object
for each and every group. I'm not sure how to do this or write this
formula as I'm new to Crystal Reports and am used to SQL Reporting
Services where this evaluation is automatically done for you (I was
spoiled I guess).For example, if the Running Totals field
control is in Group #1, I want it to reset at Group #1, and Group#2 to
reset at Group #2, etc without having to create a field for each group.So
basically I'm attempting to use a formula to create a Reset point (view
screenshot for detail) that is determined by which group the data is
being calculated in. Is this possible? I realize that it is possible by
simply creating a new running total object for each group and telling
it to reset on change of group specified, but this seems completely
redundant and overly time consuming for larger reports where there are
multiple groups and a lot of Running totals fields.I'm developing the report with Crystal Reports within Visual Studio 2005 if that helps any.I
don't know if you'll be able to see it, but I have a screenshot link to
explain what I'm trying to do. http://www.codeguru.com/forum/attachment.php?attachmentid=19302Thanks!Hi Abhilash,
Thanks for the code, but the totals aren't right still yet.
Also, I just noticed my running total is not functioning properly. Count be the reason for my delima.
Any suggestions on how to get the running total to function properly?
What I just noticed is:
Date Patient Count
7/9/13 Patient A 7
8/8/13 Patient B 8
8/8/13 Patient B 8
8/8/13 Patient C 8
8/8/13 Patient D 8
8/15/13 Patient E 9
Would I be better off to do a formula vs a running total? -
Oracle report running total Resseting balance
Dear All,
I am developing report on Oracle R12 fixed Assets, I have to calculate the running total for each asset.
In brief
Asset 1
cost Deprciation Adjusted Cost
50 - 2 48
48 -5 45
45 - 4 41
I achieved that by using
if :p_val is null then
:result := nvl(:cost,0)-nvl(:depriciation,0);
:P_val :='5';
return :result;
else
:result := nvl(:result,0)-nvl(:depriciation,0) ;
return :result;
end if;
working fine
But problem is when the next asset start on same report
Asset 2
cost Deprciation Adjusted Cost
100 5 36
it substracts the last total (running total of previous asset with depriciation which was 41 in this example).
Oracle Champs pl advice me how to solve this.
I really dont got any idea how to solve this.
thanksDear,
Thanks for your reply , in your reply what you said I tried this but in pl/sql I am not actually achieving the result. The balance is not resetting at next group if you give one accurate line it would be really helpfull.
thanks -
Running total of calculated field in pivot
VERSION: ORACLE 11
TABLE:
create table chart_detail (
DIS NUMBER,
BLD_MO VARCHAR2(7),
BLD NUMBER(10),
RPLC NUMBER(10));DATA:
insert into chart_detail values (60,'2011-03',0,2);
insert into chart_detail values (150,'2011-04',10572,0);
insert into chart_detail values (120,'2011-04',26449,5);
insert into chart_detail values (30,'2011-04',0,1);
insert into chart_detail values (60,'2011-04',0,7);
insert into chart_detail values (90,'2011-04',0,9);
insert into chart_detail values (120,'2011-05',5714,0);
insert into chart_detail values (90,'2011-05',24557,1);
insert into chart_detail values (60,'2011-05',0,4);
insert into chart_detail values (30,'2011-05',0,0);
COMMIT;EXPECTED RESULTS:
2011-04 2011-05
DIS RPLC BLD TBLD IPTV RPLC BLD TBLD IPTV
30 1 0 37021 0.03 0 0 30271 0.00
60 7 0 37021 0.22 4 0 30271 0.13
90 9 0 37021 0.46 1 24557 30271 0.17
120 5 26449 37021 0.59 0 5714 5714 0.17
150 0 10572 10572 0.59 0
180 0 0
TOTAL 22 37021 5 30271 PROBLEM: I need to have a running total of IPTV like in the above example. I can get the IPTV for each DIS/bld_mo but I don't know how to get the running total of it. In the script below I just used an example where I tried summing the IPTV like was done for build. I know it can't be done that way because IPTV is a calculated field in the query but if I substitute "APR_IPTV" with the formula for IPTV I get an error that window functions aren't allowed here. I do not know a way around this. I commented out the bad piece of code.
PROBLEM SCRIPT:
WITH pivot_results AS
SELECT dis
, NVL (apr11_rep, 0) AS apr11_rep
, NVL (apr11_bld, 0) AS apr11_bld
, NVL ( SUM (apr11_bld)
OVER (ORDER BY dis DESC)
, 0
) AS apr11_tbld
, DECODE(NVL ( SUM (apr11_bld)
OVER (ORDER BY dis DESC)
, 0),0,0,ROUND(NVL(apr11_rep, 0)*1000/ NVL ( SUM (apr11_bld)
OVER (ORDER BY dis DESC)
, 0),2
)) AS apr11_iptv
, NVL ( SUM (apr11_iptv)
OVER (ORDER BY dis DESC)
, 0
) AS apr11_tiptv
, NVL (may11_rep, 0) AS may11_rep
, NVL (may11_bld, 0) AS may11_bld
, NVL ( SUM (may11_bld)
OVER (ORDER BY dis DESC)
, 0
) AS may11_tbld
, DECODE(NVL ( SUM (may11_bld)
OVER (ORDER BY dis DESC)
, 0),0,0,ROUND(NVL(may11_rep, 0)*1000/ NVL ( SUM (may11_bld)
OVER (ORDER BY dis DESC)
, 0),2
)) AS may11_iptv
, DECODE(NVL ( SUM (may11_bld)
OVER (ORDER BY dis DESC)
, 0),0,0,ROUND(NVL(may11_rep, 0)*1000/ NVL ( SUM (may11_bld)
OVER (ORDER BY dis DESC)
, 0),2
)) AS may11_tiptv
FROM chart_detail
PIVOT ( MAX (rplc) AS rep
, MAX (bld) AS bld
FOR bld_mo IN ( '2011-04' AS apr11
, '2011-05' AS may11
SELECT CASE
WHEN GROUPING (dis) = 0
THEN TO_CHAR (dis)
ELSE 'Total'
END AS dis
, SUM (apr11_rep) AS apr11_rep
, SUM (apr11_bld) AS apr11_bld
, SUM (apr11_tbld) AS apr11_tbld
, CASE
WHEN GROUPING (dis) = 0
THEN SUM (apr11_iptv)
END AS apr11_iptv
, SUM (apr11_tiptv) AS apr11_tiptv
, CASE
WHEN GROUPING (dis) = 0
THEN SUM (apr11_tpiptv)
END AS apr11_tiptv
, SUM (may11_rep) AS may11_rep
, SUM (may11_bld) AS may11_bld
, SUM (may11_tbld) AS may11_tbld
, CASE
WHEN GROUPING (dis) = 0
THEN SUM (may11_iptv)
END AS may11_iptv
FROM pivot_results
GROUP BY ROLLUP (dis)
ORDER BY pivot_results.dis
;Thank you,Hi,
So you know how to compute iptv for an individual row; the problem now is that you want to get a running total of iptv; is that it?
The problem there is that computing iptv requires an analytic function, and analytic functions can't be nested. To get the results of nesting f (g (x)), where f and g are analytic funtions, you have to compute g in a sub-query, and then use the results as the argument to f in a super-query.
Here's how to apply that to your situation:
WITH pivot_results AS
SELECT dis
-- April, 2011
, NVL (apr11_rep, 0) AS apr11_rep
, NVL (apr11_bld, 0) AS apr11_bld
, NVL ( SUM (apr11_bld)
OVER (ORDER BY dis DESC)
, 0
) AS apr11_tbld
, NVL ( 1000 * apr11_rep
/ NULLIF ( SUM (apr11_bld) OVER (ORDER BY dis DESC)
, 0
, 0
) AS apr11_iptv
-- May, 2011
, NVL (may11_rep, 0) AS may11_rep
, NVL (may11_bld, 0) AS may11_bld
, NVL ( SUM (may11_bld)
OVER (ORDER BY dis DESC)
, 0
) AS may11_tbld
, NVL ( 1000 * may11_rep
/ NULLIF ( SUM (may11_bld) OVER (ORDER BY dis DESC)
, 0
, 0
) AS may11_iptv
FROM chart_detail
PIVOT ( MAX (rplc) AS rep
, MAX (bld) AS bld
FOR bld_mo IN ( '2011-04' AS apr11
, '2011-05' AS may11
SELECT CASE
WHEN GROUPING (dis) = 0
THEN TO_CHAR (dis)
ELSE 'Total'
END AS dis
-- April 2011
, SUM (apr11_rep) AS apr11_rep
, SUM (apr11_bld) AS apr11_bld
, SUM (apr11_tbld) AS apr11_tbld
, CASE
WHEN GROUPING (dis) = 0
THEN ROUND ( SUM (SUM (apr11_iptv))
OVER (ORDER BY dis)
, 2
END AS apr11_iptv
-- May 2011
, SUM (may11_rep) AS may11_rep
, SUM (may11_bld) AS may11_bld
, SUM (may11_tbld) AS may11_tbld
, CASE
WHEN GROUPING (dis) = 0
THEN ROUND ( SUM (SUM (may11_iptv))
OVER (ORDER BY dis)
, 2
END AS may11_iptv
FROM pivot_results
GROUP BY ROLLUP (dis)
ORDER BY pivot_results.dis
;Output:
APR11 APR11 APR11 APR11 MAY11 MAY11 MAY11 MAY11
DIS _REP _BLD _TBLD _IPTV _REP _BLD _TBLD _IPTV
30 1 0 37021 .03 0 0 30271 .00
60 7 0 37021 .22 4 0 30271 .13
90 9 0 37021 .46 1 24557 30271 .17
120 5 26449 37021 .59 0 5714 5714 .17
150 0 10572 10572 .59 0 0 0 .17
Total 22 37021 158656 5 30271 96527As you can see, this is not quite what you wanted on the row where dis='150'. You asked for NULLS in the may11_rep, may11_bld and may11_iptv columns. You can get those results if you need them; just explain the rules that govern whether to display the values and when to display NULL.
The way you posted the sample data and results, and the quantity of sample data were all excellent; it really helped me find a solution. Thanks.
It would have also helped it you had explained how iptv is computed. Basically, iptv = 1000 * rep / tbld, right?
It looks like most of this code:
, DECODE(NVL ( SUM (may11_bld)
OVER (ORDER BY dis DESC)
, 0),0,0,ROUND(NVL(may11_rep, 0)*1000/ NVL ( SUM (may11_bld)
OVER (ORDER BY dis DESC)
, 0),2
)) AS may11_iptvwas a way of avoiding divide by 0 errors; it would have been helpful if you had explained that. -
Running total across 2 grouping
Hi All
I have created a crystal report and i have 2 remaining issues that i just cant get around.
the report is basically about all the net stock position.
the report is based on a query..that links sales order to all target documents that originate from the sales orders, i.e...deliveries, invoices, returns, credit notes.
then i also brought in all the open purchase orders and the instock from the oitw
i then sumed up the lines so the sales order > Delivery > invoice > credit note > returns all shows in one line..and if there is a different unit of measure it will be another line for that sales order
the report is grouped:
per warehouse
per item
per Sales Order Num
per Item Unit of Measure
per Line Num
1st issue:
in the selection criteria if the sales order is closed but if one of the delivery notes is open it should bring in the "whole set" not just the the open deliverys linked to the sales order.
this is because the delivered quantities adds up to the net position of the stock.
2nd issue:
I have to work out a net postion
formula: net stock = Oitw.instock + PO - remaining qty on sales order
I got the sales order as a negative
i used a running total formula, but it does not work if the sales order has more then one unit of measure.
whileprintingrecords;
If onfirstrecord or previous({Command.SO No.})<>{Command.SO No.} then
numbervar remain_bal:= remain_bal + {@QTY}
i tried to add another if statement..but does not work
whileprintingrecords;
If onfirstrecord or previous({Command.SO No.})<>{Command.SO No.} then
If onfirstrecord or previous({Command.SO Uom)<>{Command.SO Uom.} then
numbervar remain_bal:= remain_bal + {@QTY}
any help will be gladly welcomed..
thank you all
JerushaHi Dave
Thank you very much for your feedback.
I have been using the base UoM, ie InvQty field.
my issues comes where i am grouping I am 1st grouping by sales order num, then by uom as the customer wants to see that as separate entries
Example:
SO Num Uom Qty InvQty
1 Bags 50 200
1 Bulk 100 100
This is the forumula for the running total:
If onfirstrecord or previous ({Command.SO No.}) <> ({Command.SO No.}) then
if ({Command.Doc Type}) = 'SO' then
SO := SO + {@QTY}
However when i "print" my total and add it to the footer.. it will show 200 instead of 300.
Thanks
Jerusha -
Need to sum hh:mm:ss in crystal report using Running Total Fields
Hello,
I am new to .Net and crystal reports so please go easy on me.
I am trying to develop a crystal report using Visual Basic .NET. I have a column which displays the "Inbound Time" in "hh:mm:ss" format. I have to sum the total inbound time and display it.
I tried using the Running Total and i am not successful.
Here is the code which I am using in the Running total
WhilePrintingRecords;
if isNumeric({Report3;1.TotalInboundTime}) then
{Report3;1.TotalInboundTime}
else
CStr ({Report3;1.TotalInboundTime});
NumberVar array test2 := [ToNumber(left(CStr({Report3;1.TotalInboundTime}),2)),ToNumber(mid(Cstr({Report3;1.TotalInboundTime}),4,2)),ToNumber(right(Cstr({Report3;1.TotalInboundTime}),2))];
StringVar test1 := CStr( (ToNumber(test2[1])3600)+(ToNumber(test2[2])60)+(ToNumber(test2[3])));
InboundTime is the time field which is in "hh:mm:ss" format.Hello Bharathi,
There are a couple of KBs about this. I haven't tested them myself, but you could give them a try:
[How sum multiple time fields in Crystal Reports|http://technicalsupport.businessobjects.com/KanisaSupportSite/search.do?cmd=displayKC&docType=kc&externalId=c2008378]
[Creating a running total to show the difference between two datetime fields |http://technicalsupport.businessobjects.com/KanisaSupportSite/search.do?cmd=displayKC&docType=kc&externalId=c2010261]
[Totalling time values that are stored as numbers in the database|http://technicalsupport.businessobjects.com/KanisaSupportSite/search.do?cmd=displayKC&docType=kc&externalId=c2005576]
Cheers,
Fritz -
Running Total & Distinct Count Query
Crystal 10.0.0.533 CR Professional
Hope you can assist.
I have a report listing deals signed, each deal has a corresponding category i.e. industry type, Accountant, Chiropractor, Financial Services, etc.
I am undertaking a Distinct Count on these categories so that in the group footer it is showing number of different categories signed in a period (the report is grouped into different date periods). This is working OK.
However, I need to EXCLUDE the category from this distinct count if the deal value is zero.
I have tried using a formula to show a blank field if the value is zero, however it appears to be distinctly counting the blank as a category?
Any assistance would be much appreciated.
TracyDeffinetly it will be less than what you expect for grand total. It is because when you are calculating distinct count for each group suppose
Group A has categories A,B,C,D-->distinct count (4)
Group B has C,D,E,F-->distinct count (4)
but while calculating grand total then the distinct count will be
A,B,C,D,E,F --> grand total (6) but not (8).
In this case you need to use mannual running total like this
whileprintingrecords;
numbervar i;
i:=i+{running total};
place this in group footer and create another fomula like this
whileprintingrecords;
numbervar i;
place this in report footer to get the correct grand total.
Regards,
Raghavendra -
How to calculate a percentage of a Running Total?
Post Author: pvang
CA Forum: Formula
Hi folks, Quite new here to the forum and to Crystal Report. As you can tell, I've already stumbled upon a roadblock. Here is what I'm trying to do:I am grabbing employee names and the number of cases that they are working via a sql query. So the sql query will result in something like 'Bob', '403'; Bob being the employee and 403 being the number of cases he's working on. In the report, I have a running total that sums up the total number of cases. I want to determine the ratio of Bob's(and every other employee's) cases over the running total amount of cases. So, for demo purposes, Bob has 403 cases and the total amount of cases is 1612, Bob's ratio would be 25%(403/1612). The equation that I am using right now is: /{#RTotal})*100 and it is not working. The ratio starts at 100%(effectively because the running total after the first record is equal to his/her cases) and then drops off dramatically. I know why it is doing that, just don't want those results. I tried using the EvaluateAfter function to no avail. Is this possible? If so, how? Many thanks in advance.Post Author: rroberson
CA Forum: Formula
Sounds to me like you don't need to use a running total. Just group on name (bob) and do a normal total (not running total) for the group (group summary). You can just divide that group summary total by the grand total (another crystal summary) and mult by 100.
Maybe you are looking for
-
Is it possible using Applescript to place a PDF as a link at a crop bounds other than Art Box?
I've spent countless hours trying to have an applescript place a PDF as an Illustrator Link at the PDF's Media Box using "make new placed item". The only result possible as far as I can tell is a link at the PDF's Art Box. I've seached around and hav
-
i hv got error in this code below..plz give solution. using System; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; using System.Configuration; using System.Data; using System.Data.OleDb; public partial class _Defau
-
How to address a component in a background tab in a JTabbedPane
Hello and greetings for everybody, this is my first post here. I have a question: I want to write a simple little chat program, which makes use of a JTabbedpane, and if the user gets a private message from another user, it would open a new tab with t
-
Question about air drop.
I have an iMac and mac book pro and it is great to be able to air drop files from one to the other. Does anyone know of a way to air drop (or other means) to transfer iPhoto contents from one computer to the other?
-
Listener refused the connection with the following error: ORA-12500
Hi, We had had some difficulties with our portal lately. All of a sudden portlets failed and started givin error messages all over our webpages. I tried to login to EM Console to try and restart Portal OC4J and got this error An error was encountered