Average calculation Problem
how can i apply the average calculation on a varchar column means only average the number values in that column and leave or return null if any character value comes in average
thanks
Hi,
Below is a conversion function, like Justin suggested.
Using this will be slower than a pure-SQL solution, so if Ankur's sulution works for you, you may want to stick with that.
CREATE OR REPLACE FUNCTION to_num
( in_txt IN VARCHAR2
, in_non_num_val IN NUMBER DEFAULT NULL
RETURN NUMBER
DETERMINISTIC
IS
-- to_num attempts to convert in_txt into a number. If it can,
-- then the value is returned. If in_txt cannot be interpreted
-- as a number for any reason (e.g., it contains letters) then
-- in_non_num_val is returned.
-- to_num (NULL) returns NULL.
BEGIN
RETURN TO_NUMBER (in_txt);
EXCEPTION
WHEN OTHERS
THEN
RETURN in_non_num_val;
END to_num;
SHOW ERRORS
Similar Messages
-
Hi,
I am finding some problem while doing the Average Calculation in the Query.
My data is like this:
Batch Stock PO Qty STO Qty
B1 1000 1000 200
B1 1000 1000 500
In the output I want:
Batch Allocated Unallocated
B1 700 300
The calculation for Unallocated is ( Stock - Allocated ).
Right now I am getting:
Batch Allocated Unallocated
B1 700 1300
What I want is to do the Average of the Stock Qty and then subtract that from the Allocatde Qty.
Can anyone help out?
Regards,
SoumenHi,
You can use the Calculated key figure (if you need top 10)...
Regards
sathis -
Major Calculation Problem?
Hi,
I've got a table with multiple columns. Each column have is average calculated at the bottom. If I put 0 (zeros) in each cell of the table, some averages are correct but some give me different results! I tried several things like changing the cells format etc.
If I make a sum instead, the problem still there. BUT, If a make the formula manually ( =sum(A1+A2+A3... etc) OR =average(A1+A2+A3... etc) ) it works! So I think that the problem comes from a bug in the span of the data (":" from, to).
I am on this problem for more than an hour now and I can't figure it out... (Google didn't help me neither)
(grrrrrrrrrrrrrrrrrr)Hi ironnickmac,
AVERAGEIF may do what you want.
A table with a Header Row and a Footer Row
Item
Item
Item
1
1
1
2
2
2
3
3
3
0
0
2
1.5
2
Formula in Footer Row A6
=AVERAGE(A)
Correct answer! (Blank cells are ignored).
Formula in B6
=AVERAGE(B)
Correct, if you want to include zeroes, not correct if you want to exclude zeroes.
Formula in C6
=AVERAGEIF(C,">0",C)
Correct answer, by including only those values >0
Regards,
Ian. -
How can I activate the average calculation with cl_salv_hierseq_table class
Hi there,
Iu2019m using class cl_salv_hierseq_table to display a two level hierarchy (header and item) list.
For some reason it seams that those calculations are active by default with class cl_salv_table but not for cl_salv_hierseq_table.
I tried every suggestion from the class documentation and SAP help and nothing seams to work, the menu calculation options are always inactive except for the total calculation.
After the cl_salv_hierseq_table=>factory...
And before cl_salv_hierseq_table->display( )
I triedu2026u2026.
cl_salv_aggregations = cl_salv_hierseq_table->get_aggregations( 1 )
cl_salv_aggregations->add_aggregation( 'COLUMN1' )
COLUMN1 is a currency column in header level table
u2026u2026..
cl_salv_aggregations = cl_salv_hierseq_table->get_aggregations( 2 )
cl_salv_aggregations->add_aggregation( 'COLUMN2' )
COLUMN2 is a dec column in item level table
u2026u2026..
cl_salv_aggregations = cl_salv_hierseq_table->get_aggregations( 2 )
cl_salv_aggregations->add_aggregation( columnname = 'COLUMN2' aggregation = if_salv_c_aggregation=>average )
u2026u2026..
cl_salv_aggregations = cl_salv_hierseq_table->get_aggregations( 2 )
cl_salv_aggregations->set_aggregation_allowed( 'COLUMN2' )
u2026u2026..
cl_salv_aggregations = cl_salv_hierseq_table->get_aggregations( 2 )
cl_salv_aggregations->set_numerical_aggregation( ).
cl_salv_aggregations->set_aggregation_allowed( 'COLUMN2' )
cl_salv_aggregations->add_aggregation( columnname = 'COLUMN2' aggregation = if_salv_c_aggregation=>average )
u2026u2026..
cl_salv_aggregations = cl_salv_hierseq_table->get_aggregations( 2 )
cl_salv_aggregations->add_aggregation( 'COLUMN2' )
cl_salv_aggregation = cl_salv_aggregations->get_aggregation( 'COLUMN2' )
cl_salv_aggregation->set( if_salv_c_aggregation=>average )
Any help will be appreciated!Thanks Harsh Bhalla,
Subtotals can be built (displayed) at Header Level Only, true but the values to calculate those totals can come from either header or item level, otherwise it wouldnu2019t be of much use would it?
Anyway my question is how to activate the average calculation as well because the totals calculations is already active for either item or header level by default.
For reference when on the display layout Iu2019m referring to the menu Edit -> Calculate -> Mean Value. -
Bug average calculation in form?
Hye,
I made an editable form in acrobat XI for mac.
I set all the fields to number and the last field I want to calculate the average of all the other fields.
So I select the fields which average I want...
But upon testing, I'm getting impossible average calculations.
F.ex. testing several fields with value "9", returns me a "0,..." value, which is impossible...
How to solve?
ThanksIt's hard to say what's happening without seeing a sample. Can you post one somewhere? Unfortunately, you can't post one here, but can at Acrobat.com, dropbox, skydrive.com, etc.
-
Urgent!!Average calculation based on a characteristic!
Hi guys
I have an average calculation based on a characteritic ..
Example:
This is a SRM Mgmt.It has an Organisation purchasing org,source purchase,PR,etc..
Report is a Survey rpt.
Average Score across Customer responded for each question for the particular PR...
Where weightage is applied for each question & based on which
total weightage of all Qns for a PR
Avg.Score= -
No of Questions.
How do u calculate using the exception aggregation??????????Pls revert ASAP.
thnx
BI LearnerSolving Myself
-
Add average calculation to FBL5N?
Hi,
My user requires an average calculation on one of the columns in FBL5N (customer line items). This is a standard transaction which uses an ALV.
I know that I can add new fields into this transaction using customizing but I need an average, so would need to create a new field and populate it with strange looking numbers in order to get an average total at the bottom.
I have seen an average calculation button on some ALVs and was wondering if it's possible to change the ALV settings in the code of FBL5N in order to get this to show? At the moment I can only total and subtotal, there is no average calculation button showing.
Or, if you can think of another solution, any suggestions gratefully received. The last resort is asking the user to download the data to excel and calculate the average there.
Thanks,
Gillhi
select the column, which u have to calculate the average .
and select edit menu ->calculate->Mean value
regards
surender -
Average calculation with joins
Hi all,
Please have a look here.,
Re: average calculation using sql
My Question is :
Is it possible to do a join here,
so that in where condition thistable.id=newtable.id
and in column area i need projects from new table.
i.e.,
Projects Name Remark SUM AVG
I tried with this query..
SELECT Projects,Name,Remark, SUM(work_hrs), AVG(work_hrs) FROM (
SELECT name,remark ,a.id,b.id,start_dt,end_dt,SUM(end_dt-start_dt) OVER (PARTITI
N BY name,remark ORDER by Name) work_hrs
FROM T a,T1 b) where a.id=b.id
GROUP BY ROLLUP(name,remark);
But o/p is not as i expect..
Thanks in advance...The alias 'b' does not exist outside of the subquery/inine view. Try to alias your subquery for clarity then refer to it;
SELECT MAX(sub.sr_pm_name), sub.ts_desc, sub.ts_remarks, AVG(sub.work_hrs)
FROM (SELECT ts_desc,
ts_remarks,
b.sr_id,
a.ts_srid,
b.sr_pm_name,
ts_expected_date,
ts_actual_date,
SUM(ts_actual_date - ts_expected_date) over(PARTITION BY ts_desc, ts_remarks ORDER BY ts_desc) work_hrs
FROM t_status_report b, t_task_status a
WHERE b.sr_id = a.ts_srid) sub
GROUP BY ROLLUP(ts_desc,
ts_remarks);Another way that might be easier to follow is to use the WITH clause;
WITH sub AS (
SELECT ts_desc,
ts_remarks,
b.sr_id,
a.ts_srid,
b.sr_pm_name,
ts_expected_date,
ts_actual_date,
SUM(ts_actual_date - ts_expected_date) over(PARTITION BY ts_desc, ts_remarks ORDER BY ts_desc) work_hrs
FROM t_status_report b, t_task_status a
WHERE b.sr_id = a.ts_srid)
SELECT MAX(sr_pm_name), ts_desc, ts_remarks, AVG(work_hrs)
FROM sub
GROUP BY ROLLUP(ts_desc,
ts_remarks); -
Average Calculation for Available Data only
Hello Gurus,
I have a requirement where I have to calculate Daily average based on Hours (24 hours). We get one reading for every hour. SO 24 readings and divide them by 24. It works fine when I do a calculation like ([Measure]/24) as Hours would always be constant.
The problem comes when we miss some readings for few hours. In that scenario User do not want to take those hours into consideration for which reading is missing.
How can I achieve that?
Any suggestions?
Regards
ShaliniHi,
Try this formula.
=sum([Measure])/count([Measure]) where ([Measure]>0)
or
=sum([Measure])/count(sum([Measure]) where ([Measure]>0))
Amit -
Y-intercept calculation problem: "A2:A7" isn't a valid reference
This is actually a problem I have with many calculations in Numbers but I will use the following as an example:
I am trying to calculate the y-intercept and slope for a set of data. Table 1 contains the raw data with each data point in triplicate. In Table 2, column 1 is the ordinate value and column 2 is the abscissa value, which is the average of the triplicates. I would like to place the calculation for the y-intercept in column 3 and the slope in column 4, but always get the error, "A2:A7" isn't a valid reference" for a result. Instead, I have to have a third table for just the y-int and slope. Why isn't A2:A7 a valid reference?No, I didn't; I only had a 5 rows but I made it 7 rows - so it was a 4 column x 7 row table - and then the formulas worked. The odd thing is that there was still only data in the first 5 rows and, after I set up the formulas, I reduced the table back to 4x7 and the formulas remained unchanged. Thanks for the help.
-
I am designing an Employee Review form and in that form I have a field that calculates the average of a set number of other fields. The problem is that the users can enter 1-5 or n, where n = no experience. I want the average field to only average the fields with 1-5 in them and skip the n fields. I have tried multiple ways of acomplishing this, but none have worked. Really could use some help on this one!!
Have you tried a "Custom Calculation Script"?
A custom calculation script will required the use of specific field names to be processed.
Unless you are computing the average on all items you might consider using a function for counting and summing the fields and values in a range of questions.
Since it is possible that no questions could be answered, you need to allow for a count of zero items being used for the computation. -
Average calculations with dates
Hi,
I have a problem with calculating the average time a call lasts. I have a start and finish time to a call that are stored in a database in datetime format. How do i find out the time of the call and then get an average over the number of calls made in a month. I have to hold the time format and show the result in the same time format that is in the database. How do you do this? I know how to do it with decimals but how to manipulate time confuses me.
Cheers
NiallYou can use the method getTime() of the class java.sql.Timestamp, which returns milliseconds in the long type, and toString() method of java.sql.Time may serve your aim here.
-
HELP !!! average calculation
Hi,
I want to calculate the average number of products sold by an agent. The formula is Avg = (nr. prod / nr. clients) where nr.prod is the number of unique products sold to a customer and nr. clients is the number of customers.
It works just fine when the customer is drilled down. In this case nr.prod is calculated fine, nr.client = 1 and the subtotal is calculated as average - that's what i want.
The problem occurs when I remove the customer drilldown - in this case the nr.prod is no more calculated as a sum of products for all the agent's customers but as the number of products for this agent.
The nr.prod and nr.client are calculated key figures as count all values for reference characteristic customer/material (in the aggregation exception).
thanx
danielthe average is calculated as nr_p/nr_c.
result with customer drilldown:
agent customer average=nr_p/nr_c nr_p nr_c
A X1 3,00 3,00 1,00
X2 2,00 2,00 1,00
X3 4,00 4,00 1,00
X4 5,00 5,00 1,00
<b>result 3,50 14,00 4,00</b>
if I hide customer then i'll have:
agent average=nr_p/nr_c nr_p nr_c
A <b>0,75 3,00 4,00</b>
nr_c = calculated key figure, aggregation =summation, aggregation exception= count all values, ref. characteristic = 0customer
nr_p = calculated key figure, aggregation =summation, aggregation exception= count all values, ref. characteristic = 0material
the problem is that I need this nr_p as sum of nr_p for each customer. How can I make this sum without the customer column ? -
Income Tax Calculation problem: Urgent Help Needed
Dear Gurus,
I am facing a unique problem. Our client has two incentives
1) Product Incentive
2) Sales Incentive
Every month incentive figures get changed. These two are Monthly Regular Income (Cumulations Class 24) i.e. included in annual tax calculation.
Now for tax calculation, my client wants "Actual Earning" and "Estimated Earning for the rest of the year" to be different. But Income tax calculation in SAP (for the month of April 2007) takes Actual Earning and multiplied it by 12( i.e. 11+1) to calculate Estimated Earning. But my client wants this Estimated Earning to be different.
Now please let me know is this possible in SAP system and how to calculate this?
Your help will be highly appreciated
Waiting for an early reply.
Thanking You,
With Best Regards,
PratikHi,
I am not understand your problem give your mb then i talk to you
mhpo -
Sale Analysis Profit Calculation problem
Hello
I create sale Invoice having Qty 2 unit price 150 & tax code is VAT@4% then Base amount is 300 & Total Bill
amt is 312.
My purchase price for the same item is INR 100 so my Gross profit show on Bill is INR 100 & profit percent
is 33.33%
Customer will debit with INR 312
But when Create Rate difference bill ie credit memo of INR 20 per uint ie Qty 2 Tax VAT@4% (maintain
drop ship warehouse in row level to can't reduce the qty)
Customer will debit -41.60
So Customer Debit balance is 270.40
But when I run Sale analysis report the result shows that Gross profit INR 260 & Gross Profit % is 100%
But actually i calculated manually the real Profit is INR 60 & Profit % should be 23.08 should be show in sale
analysis
So what i do to see the same resultHi
There is some problem in sales analysis report in some of the sap versions. Refer the following documents.
[https://websmp130.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/sno/ui_entry/entry.htm?param=69765F6D6F64653D3030312669765F7361706E6F7465735F6E756D6265723D3030303130313637303426]
[https://websmp130.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/sno/ui_entry/entry.htm?param=69765F6D6F64653D3030312669765F7361706E6F7465735F6E756D6265723D3135383735363826]
[https://websmp130.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/sno/ui_entry/entry.htm?param=69765F6D6F64653D3030312669765F7361706E6F7465735F6E756D6265723D3136363835363426]
Regards,
Sudhir B.
Maybe you are looking for
-
User Information in the log file
Hi All, Customer wants to know if it is possible to get information in the log files as to which users have accessed the documents. Any help would be much appreciated Regards, Geeta
-
How to transfer album made in iPad to mac
I downloaded all my photos from my camera to ipad while on vacations. I have created albums in ipad. I am home now and wanted to transfer those albums from ipad to mac. Would anyone please suggest solutions?
-
Hi All, In Service Purchase order Version is not coming. So, please suggest any setting is available for this. Thanks in advance... Sanjay
-
Execute .bat file using cfexecute tag...
Hello, I am trying to execute a batch file using cfexecute tag. This batch file needs 1 command line arguement, which I am passing using arguments Text attribute. When I run my batch file directly from command prompt, it works perfectly. but while us
-
Using Dual Layer DVD with iDVD
I have a 2 hour movie that I have imported into iDVD. I put in a dual layer DVD-R, but iDVD insists that my two hour movie can fit on a single layer DVD-R. Yes, I'm sure it can crunch the heck out of it, but I want the quality to be high--THAT is why