Form 6i: filtering data on a running total
I need to create a column in a group to represent a running total. But I want that running total to only sum rows that meet specific criteria, such as (:m_form.cost) <> 0. How can I accomplish this?
Thank's in advance!
[email protected]
se deben crear dos campos nuevos en el bloque, uno que te calcule el valor deseado determinado por las condiciones dadas, este campo debe tener el pl/sql necesario para determinar el valor, en la seccion calculation-->formula (property palete) (ej. if <condicion> then :campo_x * 1 else :campo_x * 0 end if;). y otro campo que sumarice al anterior, teniendo este "sum" en la seccion summary Function, y el campo anterior en summarized item. Si no me entiendes o esa no era tu pregunta devuelveme y te la escribo en ingles.
Similar Messages
-
Running Total Issue: How to calculate counts excluding suppressed records
Post Author: benny
CA Forum: Formula
Hello All:
I have a current report that gives the total counts of work requests. However, in my section expert, there are some records in the detail that are suppressed (if there isn't any backlog). The current running totals are counting all the records including the suppressed records. I think I need three formulas:1. Calculate the counts2. Calculate the counts excluding suppressed records3. Reseting the counts by group
May I ask if someone can give me an example of what I should do?
Thanks so much!
BennyPost Author: benny
CA Forum: Formula
Bettername,
Actually, I should have been more specific. This report is actually a PM backlog report. It displays all the work requests (PM) issued including the backlogged. There are 9 columns (including one called Backlog) for the different counts of the pm's based from the status codes (Issued, Material on Order, Completed, Cancelled, etc) of the work requests. The detail records of worke requests are grouped by shop and PM end date. The running totals are calculated at the pm date group level (group footer#2). Then based from those at the shop group level (group footer#1) there is a grand total of counts of the running totals. The detail records and pm end date group header (group header #2) are suppressed.
Now the foremen would like the report to just display all the backlogged PMs. Using the section expert, I suppressed all the PM issued that have no back log ({@ backlog = 0}) and just display the back logged pm's. This is where I run into the running total issue.
This is very involved report and I will use the column PM Issued as an example. I can still use the same logic as you suggested?
1. declaration formula:
whileprintingrecords;numbervar pmissued := 0;
2. Suppression formula that uses the variable:
whileprintingrecords;
numbervar pmissued;
if ({@ backlog = 0}) then pmissued:= pmissed else pmissued:=pmissuedr+1
3. Display formula:whileprintingrecords;
numbervar pmissued;
If this is the right track, then I can use the same example for the other columns.
Thanks so much.
Benny -
Running Total in forms 4.5
Hi,
I have a forms 4.5 with a master and detail block.
The detail block displays 15 record at a time. There is a column in the detail field whose total is to be displayed at the bottom.
I am using post-query to sum this item and display it at the bottom.
The solution works fine fine if the detail block has 15 or less records and the running total is displayed correctly.
But If I query a master records where there are 20 detail records then the total sum at the bottom only show sum of the 15 detail records that are displayed and not 20.
For that I have to navigate to record 15, key next , 16 and so on then the post-query trigger fires and add the rest of the records and displays the correct total.
I have tried to change the record buffered/fetched in the detail block query but it does not help.
Can anyone suggest a solution for this problem in forms 4.5?
Thanks
JakhTry Last_record instead of next_record.
Any other suggestion is that.
You must have a primary key and foreign key in your master detail form. Then why dont you write a select statement on POST-QUERY:
You have a master block (master) having columns invoice_id, date, cust_id and have a detailed block (detail) having columns invoice_id (using as foreign key from master table block) and item_id, item_description, quantity, amount
Write query on POST-QUERY on detail block as
select sum(amount) into :control_block.total from detail where detail.invoice_id = :master.invoice_id
or select sum(amount) into :control_block.total from detail where detail.invoice_id = :detail1.invoice_id;
it should give you the required result. I have used it and its working fine for me.
Thanks.
Hassan -
How can implement running total in oracle forms
I want to implement a running total in oracle form
like
100 100
300 400
200 600
500 1100
200 1300
100 1400
PROCEDURE calculate_srno IS
current_rownum integer:=:System.Cursor_Record;
starting_srno integer:=:rs_1;
last_rownum integer;
BEGIN
last_record;
last_rownum:=:system.cursor_record;
go_record(1);
FOR counter IN 1..last_rownum LOOP
:sum_1:=:rs_1;
:rs_1:=:sum_1+:rs_1;
-- :offered_srno_to:=starting_srno;
if last_rownum=:System.Cursor_Record then exit;
end if;
END LOOP;
END;
it is not working after want to insert between in the tableWhy write code for this? Oracle Forms 10g has Calculated/Summary fields that will do this for you without the need of writing any PL/SQL.
Simply add a non-table item to the data block with the item you want to keep the running total for. Then change the following properties of the item:
Data Type: Number
Calculation Mode: Summary
Summary Function: Sum
Summarized Block: <Your Data Block>
Summarized Item: <Your Block Item>
Number of Items Displayed: 1 (if your item is in a Multi-Record (Tabular) layout else you don't need to change this property.
You will also need to change the following property of the block: Query All Records: Yes
If changing the Block's "Query All Records" property causes your form to be too slow because of the number of records in your block, then you could keep a running total manually by using a combination of the Post-Query and When-Validate-Item (WVI) triggers. If your block does not allow data entry, then you could do this with just the Post-Query trigger. For example:
BEGIN
/* This code sample assumes you have added a non-table item */
/* to your block called SUMMARY. */
:YOUR_BLOCK.SUMMARY := :YOUR_BLOCK.SUMMARY + NVL(:RS_1,0);
END;If your block allows data entry, then you would add the following to your existing WVI trigger.
BEGIN
/* Perform your data entry validation logic first... */
IF ....
ELSE
...Validation is successful...
:YOUR_BLOCK.SUMMARY := :YOUR_BLOCK.SUMMARY + NVL(:RS_1,0);
END IF;
END;Hope this helps.
Craig... -
How to create a loop to run total of records for before and after unconstant date
Post Author: Ann2
CA Forum: Formula
Here is the data sample:
ID period code date
1 00 I 01/01/1999
1 00 Z 01/02/1999
1 00 G 12/05/1999
1 00 M 01/01/2000
There are many students with many periods and many codes. I need to save a date when code = 'G' and count separateley records per student/period 2 times - before and equal that date and after that date, so in the end for period 00 I will have 2 values: 3 (before) and 1(after).
There are periods from 00 to 08. I am counting students abscencies before and after warning letter was sent (code G).
The result data should look : 00 01 02 03 04 05 06 07 08 00 01 02 03 04 05 06 07 08 Total
3 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 4
Please help me.
Thank you.
Ann2Post Author: Ann2
CA Forum: Formula
Thank you for your answer, but I do care about the date the 'G' happened, because I need to reset count.
The logic behind is this:if a student absent for more than 8 times per period - the letter will be sent out to the parents , that will be code 'G' with period '-1' (it may happen that there will never be code 'G' , but I need to track all absencies). Once the letter is sent, the count starts over (the count starts over the next day after code 'G'). The absencies which happened before or the date the letter sent should count toward 'previous' abscenices, all other - absenices after the letter.
So basically I need total per period and total per period before or the day with code 'G'. Running total with reset with formula code = 'G' does not work.
I created a formula field which has global date (when code 'G' happenned) and it says if globaldate >= periodDate then date (1900,01,01) else (2100,01,01) and that formula is ok, but I can not use it in running total or can not create group on it and insert total.
Please help me with this. Thank you.
Ann2 -
Here is a sample of my data in an array collection ["Jan-08",
"Jan-08", "Jan-08", "Feb-08", "Feb-08", "Mar-08", "Mar-08"] What I
would like to do is create a running total/count that I could then
graph. I believe I would want to create another array collection
that looks like this [{month:"Jan-08", total:3}, {month:"Feb-08",
total:5}, {month:"Mar-08", total:7}] I could create a nice line
graph from this data.
Any thoughts on how to get started? I am pretty new to flex,
actionscript, and programming, so I appreciate your help.
-HunterDrobells I am certain our prepay
customer service team will be able to help with any tracking options possible
on your Mifi device. You can contact them directly at at 888-294-6804.
BryanS_VZW
Follow us at Twitter @vzwsupport -
Running total for item availbe qty. from On Hand - SO + PO by promise date
I stuck with Balance(running total).
How to link item number with SO and PO?
Need daily item qty. available qty from "On Hand" Qty. + PO - SO by promise date and sort by ascending?
Item# Order Date SO/PO PromiseDate Qty Bal.
AE01 08/01/08 OnHand 20 20
08/02/08 SO#1877 08/05/08 -3 17
08/04/08 SO#2044 08/08/08 -6 11
07/22/08 PO#632 08/10/08 10 21
Thanks.create a group by promise date
2nd group by po#
put the fields either in the group or in the details
PO#, PO promise date, qty and SO#, SO promise date, qty then availability qty
manual running totals
create 3 formulas
1 reset
WHILEPRINTINGRECORDS;
NUMBERVAR ITEMLOC := 0;
place in the group header on what you want the total to reset by (po#)
1 calc
WHILEPRINTINGRECORDS;
NUMBERVAR ITEMLOC := ITEMLOC +(qty};
this gets placed where the calculate will take place (next to qty)
1 display
WHILEPRINTINGRECORDS;
NUMBERVAR ITEMLOC;
ITEMLOC
this gets placed in the group footer.
for each field that gets calculated by a group create 3 formulas for each
they need to have the same variable name to reference each other.
if you need to create a 2nd set to calc something else give that a new variable name. -
Running Total (or) Moving Sum (or) Rollup using Date functions
I have to pass the Begin date and End date using prompt in my application (for daily basis for one month, monthly and yearly).
How can i use the date function for Rollup the days values(running total) for the below mentioned SQL
Table.Date field (@Prompt('Begin_Date','D',,mono,free) and @Prompt('End_Date','D',,mono,free)
@prompt automatically takes the begin date and end date.
I need the sql for rollup(running total) on daily basis for one month say jan 1 to jan 31.
Any idea?Check the Oracle on-line documentation on the ROLLUP option of the GROUP BY clause. It should be able to give you running totals.
-
Running totals help required. Total PartNumber when in Date Order / Group.
I am trying to create a shortages list of our order book for all our customers orders outstanding. I want a running total of the orders which works until I group the orders in date order, not PartNumber order. It needs to be in date order so the users has a priority order for jobs. What is the best ways to do a running total of the quantity required where the PartNumbers match but keep it in date order.
Hi,
Welcome you post on the forum.
Do you need query for one selectable PartNumber or all PartNumbers?
Thanks,
Gordon -
CALCULATE RUNNING TOTALS FOR SUBSETS OF THE DATA IN A SECTION
How can I calculate a running total in BO XI Release 2, (WebI), where my totals only include the value of the current row and the previous 5 rows?
For Example:
In the data, behind my BO table, I have transaction dates that roll up to a dimension called Period. The "Period" represents the Year and Month of the transaction date, which is a month's worth of data at a time. Each month contains an aggregated value that is the Population of items for that month. The RunningSum function in BO works well, except that I need the running total to only include the current month along with the last 5 months, for a total of 6 months worth of data per row.
See my example below. The Period of JAN 2009 includes the Population for JAN 2009 plus the sum of the Populations from AUG 2008 through DEC 2008 for a total of 6 months worth of data. FEB 2009 includes SEP 2008 through FEB 2009. MAR 2009 includes OCT 2008 through MAR 2009...
__________Period_______Population_______6 MOS
__________200801__________54___________54
__________200802__________60__________114
__________200803__________50__________164
__________200804__________61__________225
__________200805__________65__________290
__________200806__________58__________348
__________200807__________70__________364
__________200808__________64__________368
__________200809__________59__________377
__________200810__________62__________378
__________200811__________66__________379
__________200812__________75__________396
__________200901__________62__________388
__________200902__________53__________377
__________200903__________63__________381
__________200904__________67__________386
Six months is obviously no magic number. I'd like the solution to be flexible enough to use for 3, 12, 18, or 24 month periods as well.Hi Frank,
can you consider building the rolling sums directly in your database using subselects in the select statement:
eg. select attr1, attr2,key2, (select sum(key1) from B where B.month<=A.month and B.month>=A.month-6) from A
Just create a key figure in your universe and add the subselect statement select sum(key1) from B where B.month<=A.month and B.month>=A.month-6 as select-clause.
ATTENTION: This is SQL pseudo code.
Regards,
Stratos -
Oracle Reports : How to Create Filtered Running Totals
I need to create a column in a group to represent a running total. But I want that running total to only count rows that meet specific criteria, such as [Field_Value_1] = 'Yes'. How can I accomplish this?
make a hidden (hidden) column in select like decode(Field_value_1, 'Yes', Val_to_Sum, 0) and make running total on that column ...
Hope This Helps -
Customer Statement Report - running total
Greetings,
Example : Customer XYZ has 3 invoices, and on the 06/02/08 cheque World Bank Acc 100200 $800 paid for
Inv 2000
02/01/08 Inv #1000 $1000
05/02/08 Inv #2000 $800
04/03/08 Inv #3000 $600
The statement should show as below:
Date Details Dr Cr Balance
02/01/08 Inv #1000 1000 1000
05/02/08 Inv #2000 800 1800
06/02/08 World Bank 100200 800 1000
04/03/08 Inv #3000 600 1600
Anyone worked on some form of balance / running total like that before in the PLD ?
Thank you
Edited by: Davinder Singh on Jan 13, 2009 10:17 AMPlease check this thread:
Re: Running Total in QLD
Thanks,
Gordon -
Dear all,
I am creating a new report which needs a conditional running total.
I need to sum the credits quantity if the following condtions are met
line_type="S" and
line_no<3
I used running total like this
Field to summarize: lab_credits2.credit_qty
Type of Summary: SUM
Evaluate: Use formula
{lab_credits2.line_type}="S" and
{lab_credits2.line_no}<3;
Reset: On change of group (Reason Code).
When I ran the report, it did not produce the right results, so I placed the line type and line no into the same Group footer and ran the report.
I found out that the report is not filtering the linetype and line no.
Result shows
Line Type ="S" - 100 - Line number =1
Line Type = "M" - 200 - Line number=6
and so on.
The report is grouped by Reason Code.
Any ideas why would it not be filtering the records?
Report Record Selection Code
{lab_credits.credit_date}>={?startdate} and
{lab_credits.credit_date}<={?enddate} and
{lab_credits.credit_status} = 2;
Status=2 is needed there to filter the Order numbers correctly.
Many thanks
Regards
JehanzebThanks James,
I have put all three in detail and used the filteration and it worked under detail section however the results when used in total SUM is produced incorrectly.
I suspect it might be of database table linkage? or maybe I have done something wrong in the report.
I am going to create another report and see if that works.
Will post info here.
Regards
Jehanzeb
Edited by: Jehanzeb Navid on Sep 4, 2008 11:55 AM
Right I found the issue however I don't know how to resolve it.
I have 4 tables in the database
1: Lab Credits - Order_num, Credit_status, Reason_code
2: Lab Credits2 - Order_num, Line_no, Line_type, Credit_qty
3: Lab Reasons - Reason_code,Reason_description
4: Oetrn2 - Order_num
This is how they are linked up
Lab_Credits_Order_num = Lab_credits2_order_num and oetrn2_order_num
Lab_Credits_Reason_code = lab_reasons_reason_Code
Report Grouping
Grouped by Reason Code
Date range - month to date
Report Record Selection
{lab_credits.credit_date} in monthtodate and
{lab_credits2.line_no}<3 and
{lab_credits2.line_type}="S" and
{lab_credits.credit_status}=2;
Now the issue
When I add sum of qty of lab_credits2_credit_qty into the report Group footer,it produces the right results However when I add
DistinctCount of Oetrn2_Order_num into the Group footer, it creates totally different Sum of Lab Credit Qty results. (Please note: The oetrn2_order_num results appear fine, however they messup Sum of Lab_credit_credit_qty).
What do you think where am I doing wrong?
It has to be something to do with table linkage.
Regards
Jehanzeb -
Need modify Running total query
CREATE TABLE DET
(DDT DATE,
DNO NUMBER,
DCODE VARCHAR2(6),
DAMOUNT NUMBER,
DINST NUMBER);
INSERT INTO DET VALUES (TO_DATE('01012010','DD/MM/YYYY'),7,1946,19674.5,NULL);
INSERT INTO DET VALUES (TO_DATE('08012010','DD/MM/YYYY'),8,1574,4800,NULL);
INSERT INTO DET VALUES (TO_DATE('08012010','DD/MM/YYYY'),8,1574,50000,208.333);
INSERT INTO DET VALUES (TO_DATE('08012010','DD/MM/YYYY'),9,1835,31600,208.333);
INSERT INTO DET VALUES (TO_DATE('08012010','DD/MM/YYYY'),6,1924,50000,232.558);
INSERT INTO DET VALUES (TO_DATE('02022010','DD/MM/YYYY'),9,1835,5000,NULL);
INSERT INTO DET VALUES (TO_DATE('02022010','DD/MM/YYYY'),9,1835,31600,131.667);
INSERT INTO DET VALUES (TO_DATE('05022010','DD/MM/YYYY'),8,1574,50000,208.333);
INSERT INTO DET VALUES (TO_DATE('10022010','DD/MM/YYYY'),6,1924,50000,232.558);
INSERT INTO DET VALUES (TO_DATE('01032010','DD/MM/YYYY'),8,1574,50000,208.333);
INSERT INTO DET VALUES (TO_DATE('01032010','DD/MM/YYYY'),6,1924,50000,232.558);
i have this query ;
SCOTT@orcl>select ddt,
2 dno,
3 dcode,
4 newdamount damount,
5 dinst,
6 newdamount-nvl(dinst,0) run_tot
7 from(
8 select ddt,
9 dno,
10 dcode,
11 damount,
12 dinst,
13 decode(nvl(to_number(to_char(ddt,'MM'))-1,0),0,damount,
14 damount-nvl(dinst,0)*(to_number(to_char(ddt,'MM'))-1)) newdamount
15 from det
16 order by ddt)
17 where dcode = '1835'
18 order by ddt,dno,damount,dinst nulls first;
it returns this result;
DDT DNO DCODE DAMOUNT DINST RUN_TOT
08/01/2010 9 1835 31600 208.333 31391.667
02/02/2010 9 1835 5000 5000
02/02/2010 9 1835 31468.333 131.667 31336.666
The results last row should appear like this;
02/02/2010 9 1835 31391.667 131.667 31260 DAMOUNT for the row 02/02/2010 (where DINST > 0 ) should be 31391.667,(closing RUN_TOT of january)
and NOT 31468.333.
The above query logic could be enitrely wrong, because the criteria laid assuming that the instalment remains same every month.
Please someone who is well-verse with Lag or Sum ..Over analytic function, correct my code.
TY.user613563 wrote:
Your query entirely missed one row with DAMOUNT 5000.
i expect the result to be;
DDT DNO DCODE DAMOUNT DINST RUN_TOT
08/01/2010 9 1835 31600 208.333 31391.667
02/02/2010 9 1835 5000 5000
02/02/2010 9 1835 31391.667 131.667 31260
Well, i for one am not following the logic here, but this will give you the results you've posted (why doesn't the row with damount = 5000 factor in to the 'running total' in any way shape or form?)
select
ddt, dno, dcode, damount, dinst, resolved
from
select
ddt, dno, dcode, damount, dinst,
case when lag(trunc(ddt, 'MM')) over (order by ddt asc) != trunc(ddt, 'MM')
then
lag(damount-dinst) over (order by ddt asc) - dinst
else
damount-dinst
end as resolved
from det
where dcode = '1835'
and dinst is not null
union all
select
ddt, dno, dcode, damount, dinst,
damount as resolved
from det
where dcode = '1835'
and dinst is null
order by ddt asc, dinst nulls first
)Edited by: Tubby on Jan 11, 2010 2:47 PM
fixed the not equals sign since the forum eats less than / greater than symbols -
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
Maybe you are looking for
-
Arrow buttons not working.
Arrow buttons stopped working once I upgraded to Mountain Lion. I thought Mavericks would fix. No luck. Any ideas? If I look in input sources, there are no arrow keys on the keyboard illustrations for US or US extended keyboards.
-
Hi! I wanted to ask an opinion: 1) You can use a Drop-Ship Warehouse in a credit note to pay the incentives for Business Partners (so as not to move the stock )? 2) What problems could there be in the accounts?
-
How handle unqiue contraint error in execute immadiate statment ?
PROCEDURE xfer_msp AS v_version_number VARCHAR2(10) := 'v1.2'; proc_name VARCHAR2(50) := 'xfer_msp'||CHR(32)||v_version_number; fact_seq_num NUMBER(15,0) := 0; -- highest seq num from previous execution hi
-
Different functionality of 'value2' Single Value component in 2008?
I've recently upgraded from cx4.5 to 2008 and have found that the single value 'value2' component behaves very different. In cx4.5, when the data was a cell with a formula there was no user interaction. Under 2008, the user can interact with the co
-
How can an client-applet connect to server-DB?
as the subject. I want the applet@client-side connect to DataBase@server-side, I am using Tomcat as engine & JDBC-mysql as tools where should the jdbc class placed in? WEB-INF/classes ? WEB-INF/lib ?? or others? now i am facing the problem that the a