Sum Formula Column
how Column formula can be calculate(addition) or addition in rtf
Edited by: user12879396 on Dec 27, 2011 12:05 AM
If you're reading in from a RTF, it sounds as if you're reading the values in as a string value. You would need to convert the string values to a number value. The following has a quick snippet on string to number conversions.
http://www.techonthenet.com/oracle/functions/to_number.php
From there, you can sum what you read in by column to a variable you define in PL/SQL.
Hope I'm reading your question correctly.
Similar Messages
-
How to display a Sum field for a formula column?
Hi,
I need to display a sum for a formula column at the end of report. for example: my formu_col=col_1-col_2
col_1 col_2 formu_col
3 1 2
6 5 1
total:sum(col_1) sum(col_2) sum(formu_col)
now i have sum(col_1) and sum(col_2), but i don't have sum(formu_col)
thanksHi
You may add a summary column in the same data group that you have sum(col_1) and sum(col_2). In that properties of the new column point the source as formu_col.
Hope this helps.
Fouwaaz -
Using PL/SQL in a formula column in Oracle Reports Builder.
Hi,
I need to SUM two record from the result of an SQL interrogation.
Here's what it looks like
function CF_1Formula return Number is
nTot1 NUMBER :=0;
nTot2 NUMBER :=0;
begin
select sum(:TOT1) into nTot1 from table(Q1) ;
select sum(:TOT2) into nTot2 from table(Q1) ;
return (nTot1 + nTot2);
end;I'm kind of new to formula column programming any link of interest would be appreciated.
The from table(Q1) part Q1 represents my SQL interrogation name and the group below it is G_MAIN.Hi Hong Kong King Kong,
From looking at that function name (and the group name): Is this an Oracle Reports generated function?
If so, there's also a dedicated Reports forum: Reports
By the way, I like your synonym for 'query'.
I'm sure I'll confuse some of my collegues tomorrow when I will mention 'database interrogation' instead of 'query'. ;)
edit
Doh...I should not underestimate the information that is posted in thread subjects.
Edited by: hoek on May 5, 2010 9:24 PM -
Formula column help needed(urgent)
Hi ,
I am using the data template for generating XML data.
BIP provided functions like SUM(), AVG(), COUNT(), MAX(), etc to use as
below
<group name="G_DEPT" source="Q1">
<element name="DEPT_NUMBER" value="DEPTNO" />
<element name="DEPTSAL" value="G_EMP.SALARY" function="SUM()"/>
<group name="G_EMP" source="Q2">
<element name="EMPLOYEE_NUMBER" value="EMPNO" />
<element name="NAME" value="ENAME"/>
<element name="JOB" value="JOB" />
<element name="SALARY" value="SAL"/>
</group>
</group>
but suppose if I want to do a sum like
Sum(ALLdebits - All credits - All refunds).
We use to have formula good old formula column. like in ORACLE Reports...
below is my query in the data template....can someone please suggest?
<dataTemplate name="R007" dataSourceRef="xyz">
<properties>
<property name="include_rowsettag" value="false"/>
<property name="include_rowtag" value="false"/>
<property name="xml_tag_case" value="as_are"/>
</properties>
<parameters include_in_output="false">
<parameter name="DATE_FROM" dataType="varchar2" include_in_output="false"/>
<parameter name="DATE_TO" dataType="varchar2" include_in_output="false"/>
<parameter name="BANK_GIRO_NUMBER" dataType="varchar2" include_in_output="false"/>
</parameters>
<dataQuery>
<sqlstatement name="Q1">
<![CDATA[SELECT
DISTINCT
SYSDATE todayDate
,substr(trim(CR_BG_NO),3,8) creditorBGNumber
,CREDITOR_SHORT_NAME creditorName
,COUNT(*) itemCount
FROM
R00777_REPORT R1
WHERE
R1.TXN_DATE BETWEEN TO_DATE(:DATE_FROM,'YYYY-MM-DD') AND TO_DATE(:DATE_TO,'YYYY-MM-DD') AND
R1.CR_BG_NO = :BANK_GIRO_NUMBER
GROUP BY
substr(trim(CR_BG_NO),3,8)
,CREDITOR_SHORT_NAME]]>
</sqlstatement>
<sqlstatement name="Q2">
<![CDATA[
SELECT
TXN_DATE
,substr(trim(CR_BG_NO),3,8)
,PAYMENT_TYPE
,TXN_SERIAL_NO
,decode(PAYMENT_TYPE,'AGDEBIT_TRANSFER',DR_TXN_AMOUNT,'AG_REFUND',-RE_TXN_AMOUNT,'AGCREDIT_TRANSFER',-CR_TXN_AMOUNT)
SIGN_AMOUNT
FROM
R00777_REPORT R2
WHERE
R2.TXN_DATE BETWEEN TO_DATE(:DATE_FROM,'YYYY-MM-DD') AND TO_DATE(:DATE_TO,'YYYY-MM-DD')
AND R2.CR_BG_NO = :BANK_GIRO_NUMBER
]]>
</sqlstatement>
</dataQuery>
<dataStructure>
<group name="response" source="Q1">
<group name="head" source="Q1">
<element name="itemCount" value="itemCount"/>
<element name="todayDate" value="todayDate"/>
<element name="creditorBGNumber" value="creditorBGNumber"/>
<element name="creditorName" value="creditorName"/>
</group>
<group name="list" source="Q2">
<group name="listItem" source="Q2">
<element name="transactionDate" value="TXN_DATE"/>
<group name="transactions" source="Q2">
<group name="transaction" source="Q2">
<element name="transactionType" value="PAYMENT_TYPE"/>
<element name="serialNumber" value="TXN_SERIAL_NO"/>
<element name="amount" value="SIGN_AMOUNT"/>
</group>
</group>
<element name="netSum" value="transaction.SIGN_AMOUNT" function="SUM()"/>
</group>
</group>
</group>
</dataStructure>
</dataTemplate>Hi Rainer,
Many Thanks for your reply
I had done all the calculations in the report view earlier
and when i accessed it in the data template as follows
<element name="netSum" value="netSum" />
the xml output that i got was like
<R007>
<response>
<head>
<itemCount>8</itemCount>
<todayDate>2009-02-05T15:50:12.000+01:00</todayDate>
<creditorBGNumber>01829209</creditorBGNumber>
<creditorName>ANDROMEDA</creditorName>
</head>
<list>
<listItem>
<transactionDate>2008-09-03T00:00:00.000+02:00</transactionDate>
<netSum>-6647999</netSum>
<transactions>
<transaction>
<transactionType>AGCREDIT_TRANSFER</transactionType>
<serialNumber>5</serialNumber>
<amount>-1687200</amount>
</transaction>
</transactions>
</listItem>
</list>
</response>
</R007>
But the output that i want is something like this
<R007>
<response>
<head>
<itemCount>8</itemCount>
<todayDate>2009-02-05T15:50:12.000+01:00</todayDate>
<creditorBGNumber>01829209</creditorBGNumber>
<creditorName>ANDROMEDA</creditorName>
</head>
<list>
<listItem>
<transactionDate>2008-09-03T00:00:00.000+02:00</transactionDate>
<transactions>
<transaction>
<transactionType>AGCREDIT_TRANSFER</transactionType>
<serialNumber>5</serialNumber>
<amount>-1687200</amount>
</transaction>
</transactions>
<netSum>-6647999</netSum>
</listItem>
</list>
</response>
</R007>
Hence I used the BIP built in template function like this
<element name="netSum" value="transaction.SIGN_AMOUNT" function="SUM()"/>
but the sum() function is adding up all amounts as expexted,I want
the above newsum value as
Sum(AGdebit-AGCREDIT-AG_refund). -
Formula Column in Matrix Report (Running Balance)
Hi all. I hope somebody can help me.
I am working on a matrix report using multi-query data models. The report has 2 groups in the horizontal axis and 3 groups in the vertical axis. The intersection is not just a single row but may consist of multiple rows.
My problem is this. I want to create a column in the intersection which is obtained by using a column value from the lowest group in the vertical axis and a summary column obtained from the rows of the intersection.
Here's what my report looks like:
2002 (accross)
2002(down) january february (accross)
January (down) payments balance payments balance
loan #1 10,000 500 9,000 200 8,800
500
loan #2 5,000 100 4,900 200 4,700
February
loan #3 3,500 0 3,500 50 3,450
loan #4 4,200 0 4,200 0 4,200
As you can see, the loans are grouped by month and year. And the payments are grouped for the month and year too.
The data model is :
For Query 1 (Vertical Axis),
1st group - Loan Yr
2nd group - Loan Mo
3rd group - Loan # and amount
For Query 2 (Horizontal Axis)
1st group - Payment Yr
2nd group - Payment Mo
Intersection Group - Payment Amount
My problem actually is how to compute for the running balance of the loan for each month in the horizontal axis. Ive already created a cross product summary to get the running total of the payments made for the month. I tried creating a formula column to for the running balance by subtracting it from the loan amount but i get the error "incompatible frequency"
I hope i have described my problem well and thanks for the helpThe problem is that you're trying to reference dimension columns(loan Amount) in the calculation of matrix cell values. You can only reference other matrix cell values or cross product columns (summary, formula, placeholders) when calculating matrix cell values. Try moving the (loan Amount) column down to the matrix cell - something like:
For Query 1 (Vertical Axis),
1st group - G_LoanYear(LoanYr)
2nd group - G_LoanMonth(LoanMo)
3rd group - G_LoanNumber(Loan#)
For Query 2 (Horizontal Axis)
1st group - G_PaymentYear(PaymentYr)
2nd group - G_PaymentMonth(PaymentMo)
Intersecion /Detail Group - G_Details(PaymentAmount, LoanAmount)
Then create the following Matrix summary columns:
A running summary - CS_Payments:
- Product Order: G_LoanYear G_LoanMonth G_LoanNumber G_PaymentYear G_PaymentMonth
- Source: PaymentAmount
- Function: Sum
- Reset At: G_LoanNumber
The total amount per loan - CS_TotalPayment:
- Product Order: G_LoanYear G_LoanMonth G_LoanNumber
- Source: LoanAmount
- Function: First
- Reset At: G_LoanNumber
The value of the loan after each payment - CF_Countdown:
- Product Order: G_LoanYear G_LoanMonth G_LoanNumber G_PaymentYear G_PaymentMonth
- PL/SQL Formula:
function CF_CountdownFormula return Number is
begin
return(:CS_TotalPayment - :CS_Payments);
end;
You should then be able to display "CF_Payments" and "CF_Countdown" in the matrix cell to show how much has been paid and how much is still owed.
You can still have another "loan amount" as a dimension column - you just don't need to use it when calculating the values in the cell. -
Dynamic SQL in Formula Column in OracleReports6i
Following code is in formula column of my report. passing dynamic sql str1(actullay, this string comes from after parameter trigger form) into SQL and executing thru DBMS_SQL.PARSE function. it's failed with 'Fatal PL/SQL error occured' ...
Coupld any one help me on this...
function CF_1FORMULA0006 return Number is
Credits1 NUMBER(10,2);
str1 VARCHAR2(50) := 'AND b.PROGRAMID = 2 ';
c1 INTEGER := dbms_sql.open_cursor;
c2 INTEGER;
begin
begin
dbms_sql.parse(c1,
'SELECT NVL(SUM(a.AMOUNT),0) INTO Credits1' | |
'FROM SPONSOR_TRAN_DATA a, SPONSOR b ' | |
' WHERE ' | |
' a.TRANTYPE = 41 ' | |
' AND a.SPONSORID = b.SPONSORID ' | |
str1 | |
'AND a.amount > 0 ' | |
'AND a.timestamp >= :reportdate ' | |
'AND a.timestamp < :reportdate + 1' ,2);
c2 := dbms_sql.execute(c1);
exception
when no_data_found then
Credits1 := 0;
end;
return Credits1;
end;
Thanks in advance......It looks like forms are not supporting text functions like FR yet, I gave it a try <<MemberName("<Formname>","<POV DIM Name>)>> in the formula header area and it didn't like it. It is just displaying what ever I typed in there.
-
Hi...
I want to ask if I have a formula Column(REPORTS 6i),and I want in where condition using parameter to some condition as this example:
function CF_1Formula return Number is
S NUMBER(10);
begin
SELECT SUM(SAL) INTO S FROM EMP
WHERE DEPTNO IN (:DEPT);
RETURN(S);
end;
Where :DEPT is user parameter of char Datatype and it is value 10,20 and may be 10,30,40
and so on.
on runtime the sql will be:
SELECT SUM(SAL) INTO S FROM EMP
WHERE DEPTNO IN (10,20);
but this not work.So what is the correct way to deal with this sql stat.,
and :dept always have different values.
So PLS any ONE help me ASAPSomething like this will work (10g onwards)
SQL> ed
Wrote file afiedt.buf
1 with req as (select '&required_empnos' as empno from dual)
2 --
3 select *
4 from emp
5 where empno in
6 (select regexp_substr(empno, '[^,]+', 1, rownum)
7 from req
8* connect by rownum <= length(regexp_replace(empno, '[^,]'))+1)
SQL> /
Enter value for required_empnos: 7839,7499,7934
old 1: with req as (select '&required_empnos' as empno from dual)
new 1: with req as (select '7839,7499,7934' as empno from dual)
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7839 KING PRESIDENT 17-NOV-81 5000 10
7934 MILLER CLERK 7782 23-JAN-82 1300 10
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
SQL> -
Dear All,
I am using BEx Query Designer to make a query.I view the report using browser. I have 2 keyfigure fields "price" and "forecast quantity". I have to arrive at "forecast Value" = price * forecast quantity using formula in Query designer. Although for each material this proves correct in report material wise. If I see the report customer-wise a customer who has bought 10 materials first the prices are added up andthen the forecast quantity is added up and then the sums are multiplied to get forecast value which is wrong.
Illustration :
Quantity Price Value(Quantity * price)
Customer 1 : Material1 2 10 20
Material2 3 10 30
Material3 5 10 50
Material4 7 10 70
Total 17 40 170 = Correct value
But if I see report customer wise I get the value as 17 * 40 = 680 which is wrong.
Is there any way when I see an aggregation of materials the calculation in formula column first multiplies individual rows and then add the rows to give me final value?
Regards,
Ratish
[email protected]hi Pratish.
Please please I'm in a hurry can you tell me how did you solve this problem?
Please... If you want to, I'll open a post to give you points... please.
Best regards...
Karim -
Hi,everyone:
I am trying to create a formular column, which will be a sum of two columns from two different queries.
In the data model, I could not put this CF_1 in neither of the two queries, so I put it outside the two queries, which is supposed to report level formula column.
When I ran the report, the error message is:
REP -1517. Column 'CF_1' references column 'Sales1' which has imcompatible frequency.
I don't where I should put CF_1 in the data model.
Thanks.
nullAll right Les,
Create a summary column CS_1 outside the queries.
Function: SUM
Source: Your 1st querys column (ex:
Reset At: Report
Likewise create another summary column CS_2 outside the queries.
Function: SUM
Source: Your 2nd querys column
Reset At: Report
Now create a formula column CF_1 which returns :CS_1 + :CS_2;
Create a layout field and have the source as :CF_1 and run the report.
Look this works for me with a simple example on EMP table. If you are not sure on where to place the layout field, then run a default layout (dont select :CS_1 and :CS_2 for display).
HOPE this works, otherwise send your email id- Ill send an example
null -
Hi,
I have a doubt in Column formula. I have a grid with a prompt selection so that users can select a list of members which will be displayed as the columns. The grid also have a total column(formula column) at the end.
For example, If the user selects three members then the grid will show the selected members and the total column. The total column should be sum of three members similarly when I select 5 members the total should be the sum of 5 members.
Is there a way to achieve this when the number of columns will be dynamic based on the user's selection?
Thanks in advance.Just choose the sum of particular column e.g. if in Column A you are selecting RTP as 5 members then at the run time it would be 5 columns , but for the summation purpose it is a single column so choose SUM([A]).
If I am not wrong it will solve your problem as I have used it long time back.
Please let me know if doesnt solve your problem.
Thanks
YSP -
Hello Everyone,
I need to know how to get the sum of two column formulas (cf_win, cf_loses) on each row and the percentage of one particular column (win %). Here is an example of how the final report should look.
SITE WINS LOSES DECISIONS WIN %
A 10 5 15 67%
B 35 10 45 78%
C 8 2 10 80%
Totals 53 17 70 76%
Thanks
RichieHi Richard,
You can achieve this with summary column.
To get the sum of formula column, put a summary column outside the query group and select the "formula column" as source and "sum" as function in property inspector.
To calculate the % you can have a formula column again.
Hope this helps
Thanks
Oracle Reports Team -
Sum formula not calculating sum accurately
Hie All,
In my Webi report, I've included a sum formula (Sum[actual hours]) for both rows and columns. However, the total is inaccurate for some rows/columns. Any idea why this could happen and how to resolve the issue? Thanks.Hi Jeewan,
You can try these but i'm not sure it will work:
1. Try merge dimension on common objects.
2. Try sum(sum([actual hours]))
3. Instead of using formula you can use the sum function available in "Analysis -> Function -> Σ Sum"
4. It can be due to the projection used at universe level for this you have to access the universe and check.
5. Try dragging some compatible objects in object browser it might happens some times that data will not come correctly.
6. last one (hit and try) check the filters once.
Hope this helps,
Thanks,
Shardendu Pandey -
FR Conditional Suppression on Formula Column
If I have 2 columns of data and 1 formula column taking the difference.
Row 1 is Base of Custom1, with conditional suppression on formula column if difference is <$5m
Row 3 is Total custom1
Row 2 is Other (ie [3] - [1].sum)
Row 1 suppresses fine, but row 2 returns zero as [1].sum is apparantly prcessed before the conditional suppression.
I've tried this before with suppression on Data columns and it worked fine. Is there a solution to this?For best practice you should put any calculated rows as the last row, in your example I suggest you move the row 2 (the calculation row [3] - [1].sum) below row 3.
FR seems to calculate each row in turn, moving down the report - therefore it can miss calculations which reference other values or calculations down the sheet. -
Hi
Hoping you can help with a formula column I need to create.
The situation is this:
It's for a HR head count report which is split by Employment category.
The issue is for multiple assignments, where in this report - I only want to count each person once, but not necessarily their Primary Assignment.
If we assume we have 3 employees, one of which has 2 assignments in different Employment Categories - each assignment has a head count of 1:
Employee A - Assignmnent AA - Employment Category A
Employee B - Assignment BB - Employment Category B
Employee C - Assignment CC - Employment Category A
Employee C - Assignment CD - Employment Category B.
As normal, the summed report of headcount would show
Employment Category A - 2
Employment Category B - 2
However, the way I need it to work is that the report will prioritise each employment category so that if an employee already has a record in Employment Category A, it won't count the record in Employment Category B. If the employee only has a record in Employment Category B, it will show though.
So the result I want is:
Employment Category A - 2
Employment Category B - 1
Is there a way for a formula to work out this priority and so only sum for Employment Category B where there doesn't exist an Employment Category A record for the same employee?
I hope I have explained this ok.
Many thanks
MartinHi
Thanks for that - I now have it working.
I am however having issues with Totals.
They are fine in Discoverer Plus but I need to run this report in Desktop.
In Desktop, I have totals for rows and totals for columns for both HeadCount and FTE.
Initially, none were showing.
After changing the aggregation option from 'Default aggregation behaviour' to 'Show the sum of the values', I now get everything except the grand total for HeadCount.
Example below
______________Head Count____________________________FTE
________Asg Cat 1______Asg Cat 2____Total______Asg Cat 1____Asg Cat 2______Total
Org1________2____________3__________5__________2____________3___________5
Org2________1____________2__________3__________1____________2___________3
Total________3____________5_____________________3____________5___________8
As you can see, I'm getting every total except the total of '8' for HeadCount but I am getting it for FTE.
I know this is often due to folder joins, but FTE and HeadCount are coming from the same folder, yet FTE is working and HeadCount isn't.
Any ideas?
Many thanks
Martin
Edited by: christm31 on May 4, 2012 10:27 AM -
Form Layout Formula Column Bar
Dear All,
Need help to create a formula column in the data form. I need to sum amount from january to september in the formula column. I'm unable to figure out the syntax.
here is the scenario,
I have column A in which I have 3 Dimension i.e. Headcount, Year, Months. I need to sum values of months from january to september.
Head Count
FY13
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
Branch Managers 2 2 2 2 2 2 2 2 2 2 2 2
Your help will be highly appreciated.
ThanksUnless you have the periods explicitly stated in the webform design, im not sure it is possible to sum up just certain periods from one column (im assuming you have selected periods as ILvl0Descendants("Time") or similar).
Someone else may be able to shed further light on this...but as far as im aware you can only reference columns or rows (in terms of [A] or [1]) within dataform formulas.
JB
Maybe you are looking for
-
ITunes only gives iPhone 5 the option to restore from backup or eject
I know this question has been asked in the past, and I have read many threads and articles on this question, but I still have not been able to find a way to backup my iPhone 5 (running iOS 6.1.2) to my computer without losing all the data on it. Brie
-
Windows Defender not working in Windows 8.1
My Windows Defender isn't working. It says update failed and cannot turn on real protection
-
Here we go. I have a Pavillion g6. On the printer/devices, my HP-computer is flagged for troubleshooting. When I take computer through process, it says my HP laser jet pro 1102W printer (wireless) needs a new driver. I've tried to install again and a
-
Oracle 10g DBCA error - not enough space on root?
Im running Oracle 10g on HP-UX 11i. Oracle software is installed ok. Already created a database succesfully. I have now deleted that database and am creating a new one using dbca. When I get to the final step I get the following error: You do not hav
-
The battery of my iPhone 5 easily discharges even when not in use. The unit was tested by Apple and passed the Battery Health Test although the performance showed otherwise. The battery deterioration started 11 months after purchase and is not covere