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
daniel
the 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 ?
Similar Messages
-
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. -
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 -
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 -
Javascript Help - Conditional Calculation
Hello:
I am trying to figure out how to perform an averaging calculation on a form. Here's my problem, I've attached a ss:
I have 4 columns, each representing a unit. In the weekly attendance summary at the bottom, I calculate the attendance percentage for that unit. The issue is that not all units have a 'Delta' sub-unit and when the Total average is calculated at the bottom right for TRAINING, I don't want to consider units that are not being used. What I did so far was set Delta's total to 100 if their attended at the top was 0 as that would mean they are not in existence. Looking for a better way to do this.
Thanks,
-eHi George:
Thanks very much for your answer. I ended up having to make a couple changes. Here's what the whole thing looks like:
What I need to figure out how to do is populate the fields under training and roll-call on the left side with calculations based on the selection in R/C or Trg. So, if I put a person's name in under Alpha and beside their name select AWOL, over on the left, I want it to add 1 in the AWOL row for Alpha.
I have no idea how to get started, although with some pointers I am sure I can figure it out. I did manage to sort out the problem from the first question I had and I am embarassed at how easy it was in retrospect. Another unrelated question, is there a way to set it up such that once you have made a selection from the combo box, the arrow to the side disappears?
Thanks again,
-e -
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
thanksHi,
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 -
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); -
I need your help in calculation script: Using 9.3.1 version
In below script , I have to write same code for total 10 account members used in the same place A and all 10 accounts members are level 0 children of 1 parent.
A = A + B / C*D
I need to write a code where 10 Account members can be used during calculation in place of A.
Please can you help me on this query .. How to achieve this requirement ...
Regards
VishalUsing my Very Favorite Essbase Database In The Whole Wide World, aka Sample.Basic, I wrote the following nonsense code snippet:
FIX(@RELATIVE("Profit", 0), @LEVMBRS("Product", 0), @LEVMBRS("Market", 0), @LEVMBRS("Year", 0))
"Actual" = "Actual" + "Actual"->"Opening Inventory" / "Actual"->"Additions" * "Actual"->"Ending Inventory" ;
ENDFIXDon't focus on why you would never ever want to do the above with inventory, just look at the code.
The code does work.
Before:
100-10 New York Actual
Jan Sales 679
COGS 271
Margin 408
Marketing 94
Payroll 51
Misc 0
Total Expenses 145
Profit 263
Opening Inventory 2101
Additions 644
Ending Inventory 2066 After
100-10 New York Actual
Jan Sales 7419.164596
COGS 7011.164596
Margin 408
Marketing 6834.164596
Payroll 6791.164596
Misc 6740.164596
Total Expenses 20365.49379
Profit -19957.49379
Opening Inventory 2101
Additions 644
Ending Inventory 2066 I can't remember if your to be affected members are under a common parent or not. If the latter, use a UDA to go after the members.
Oh yes, this code violates one of my personal design considerations -- it modifies the source data so it can only be run once. That is really dangerous but the choice is yours.
Regards,
Cameron Lackpour -
Please help in calculating average from random nos. generated
Actually i am new to LV and i don't understand e'thing pretty well. Can anyone please help me with this problem?
I have to construct a VI that displays a random no. once every sec., and then in the same VI, i am trying to compute the average of the last four nos. generated, i.e. the average is displayed only after 4 numbers have been generated, else the average displays zero.
Well, i was trying to get this, but so far what i have got is a VI that is generating average, but that is not what i need.
Thanks for any help.
CLEasiest would be to use "Mean PtByPt.vi" in the Analyze...Point by Point palette. It is most flexible, e.g. if you would want to change the averaging length in the future.
Alternatively, you could use shift registers initialized with NaN. I would prefer NaN over zero for incomplete samples, zero is not unique, it could be a legal value. See attached simple example (LabVIEW 7.1). Modify as needed.
LabVIEW Champion . Do more with less code and in less time .
Attachments:
Average4.vi 31 KB -
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. -
Query Scenario Help - Average of Multiple Regions
Hi, I have a query scenario I can't create and I hope someone can help with.
The user inputs a sales Area and the report is to output the regions in that area and provide the Volume (easy) and the Average of all the presented regions. The problem is that the number of regions is dynamic so I don't know how to go about determining the average and making it constant across the regions. The user can also drill down on a region to present divisions and I would then need the average for the divisions this time instead of regions. Can you help?
Example 1
Input Sales Area 1000000
Region 1000001 1000002 1000003
Product1 Volume 100 120 105
Product1 Average 108 108 108
Product2 Volume 200 400 325
Product2 Average 308 308 308
Example 2
Input Sales Area 2000000
Region 2000001 2000002 2000003 2000004
Product1 Volume 100 120 105 180
Product1 Average 126 126 126 126
Product2 Volume 200 400 325 600
Product2 Average 381 381 381 381
To get this layout I have the following in the query builder:
The 2 Products are in a structue under Rows
The Key figures structure is also under Rows
The Region is under the columnsIf you redesign the report slightly to move the "Average" to a column at the end of each row (which really makes more sense, IMHO), then the answer is easy. Just change the Suppress Results Row property to "Never" for Region, and change the Display Results As property to "Average" for Volume.
You could also make this same change to Division and/or any other free characteristic they might use as a drill-across in the report.
Hope this helps...
Bob -
Help with calculations in XMLP Template
Hi,
I would like to get some guidance on how the below could be done in XMLP. I am getting the 'Amount' column from FSG and would like to calculate the percentage in the template. Is it possible to calculate rows and store results in column like in the example below in XMLP? Many thanks for your help.
Type-------Amount-----%
Gross-----------10-----166.7 (Gross/Net*100)
Discount---------4-------66.7 (Discount/Net*100)
======================
Net (G-D)--------6-----100.0 (Net/Net*100) or (Gross% - Discount%)Hi Hazan,
I have done a similar Gross Margin Report using XMLP 5.5.
I have used the concept of variables to store temporary values in my report and carry out complex calculations.
Please let me know what version of XMLP are you using?
Some of my form fields containing variables look like this:
<?xdoxslt:set_variable($_XDOCTX, Sum1, CS_TCOST + CS_TCOST1)?>
<?xdoxslt:get_variable($_XDOCTX, Sno )?> <?xdoxslt:set_variable($_XDOCTX, Sno, xdoxslt:get_variable($_XDOCTX, Sno) + 1)?>
<?xdofx:if(CS_TSELL + CS_TSELL1) <= 0 then
xdoxslt:set_variable($_XDOCTX, Sum1, 1)
end if?>
I am not sure if you are looking at this or not. Do let me know if this solves the purpose and need be required some help :-o)
HTH,
Nitin -
Need help with calculating interest
Hey im trying to find out where my calculations are screwing up on the interest is coming up wrong but i am unable to find out where. After every month its suppose to be deposit - withdrawl * monthly interest rate and then add that total to the new month etc... any help will be appreciated. Heres my class and test
public class SavingsAccount
private double bal;
private double intRate;
The constructor initializes an object with a
balance and an annual interest rate.
@param bal The account balance.
@param intRate The annual interest rate.
public SavingsAccount(double bal, double intRate)
bal= 0.0;
intRate = 0.0;
The withdraw method withdraws an amount from
the account.
@param amount The amount to withdraw.
public void withdraw(double amount)
bal -= amount;
The deposit method deposits an amount into
the account.
@param amount The amount to deposit.
public void deposit(double amount)
bal += amount;
The addInterest method calculates the monthly
interest and adds it to the account balance.
public void addInterest()
// Get the monthly interest rate.
// Calculate the last amount of interest earned.
// Add the interest to the balance.
intRate = bal * (intRate/12);
bal += intRate;
The getBalance method returns the account balance.
@return The account balance.
public double getBalance()
return bal;
The getInterestRate method returns the annual
interest rate.
@return The annual interest rate.
public double getInterestRate()
return intRate;
The getLastInterest method returns the last amount
of interest earned.
@return The last amount of interest earned.
public double getLastInterest()
return bal;
import java.util.Scanner;
import java.text.DecimalFormat;
public class SavingsAccountTest
public static void main(String args[])
// Annual interest rate
double intRate;
// Starting balance
double startBal;
// Amount of deposits for a month
double deposit;
double totalDeposit;
// Amount withdrawn in a month
double withdrawn;
double totalWithdrawn;
// Interest earned
double intEarned = 0;
// Deposit accumulator
deposit = 0.0;
totalDeposit = 0.0;
// Withdrawal accumulator
withdrawn =0.0;
totalWithdrawn = 0.0;
// Months that have passed
double months;
// Create a Scanner object for keyboard input.
Scanner keyboard = new Scanner(System.in);
// Get the starting balance.
System.out.println("What is your account's starting balance");
startBal = keyboard.nextDouble();
while (startBal < 0)
startBal=0;
// Get the annual interest rate.
System.out.println("What is the annual interest rate?");
intRate = keyboard.nextDouble();
while (intRate <= 0 )
intRate = 0;
// Create a SavingsAccount object.
SavingsAccount account = new SavingsAccount(0.0, 0.0);
// Get the number of months that have passed.
System.out.println("How many months have passed since the " +
"account has opened? ");
months = keyboard.nextDouble();
while (months <= 0)
months = 1;
// Get the deposits and withdrawals for each month.
for (int i = 1; i <= months; i++)
// Get the deposits.
System.out.println("Enter the amount deposited during month " + i);
deposit= keyboard.nextDouble();
totalDeposit += deposit;
while (deposit <=0)
deposit = 0;
// Get the withdrawals.
System.out.println("Enter the amount withdrawn during month " + i);
withdrawn = keyboard.nextDouble();
totalWithdrawn += withdrawn;
while (withdrawn <= 0)
withdrawn = 0;
// Add the deposits to the account.
startBal += deposit;
// Subtract the withdrawals.
startBal -= withdrawn;
// Add the monthly interest.
intRate = startBal * intRate/12;
startBal += intRate;
// Accumulate the amount of interest earned.
intRate += intEarned;
// Create a DecimalFormat object for formatting output.
DecimalFormat dollar = new DecimalFormat("#,##0.00");
// Display the totals and the balance.
System.out.println("Total deposited: " + dollar.format(totalDeposit));
System.out.println("Total withdrawn: " + dollar.format(totalWithdrawn));
System.out.println("Total interest earned: " + dollar.format(intEarned));
System.out.println("Account balance: " + dollar.format(startBal));
}Ok this is what i have fixed up so far but im still having trouble calculating the interest. Problem1) We were given the skeleton to the class and demo. I cannot figure out what to enter in getLastInterest.(completely lost all i need is hint) 2)When i try to get the Total money deposited and i call the account.deposit(balance) it keeps on giving an error void not allowed. Any help is appreciated
public class SavingsAccount
private double balance;
private double interest;
private double intEarned;
The constructor initializes an object with a
balance and an annual interest rate.
@param bal The account balance.
@param intRate The annual interest rate.
public SavingsAccount(double bal, double intRate)
balance = bal;
interest = intRate;
The withdraw method withdraws an amount from
the account.
@param amount The amount to withdraw.
public void withdraw(double amount)
balance -= amount;
The deposit method deposits an amount into
the account.
@param amount The amount to deposit.
public void deposit(double amount)
balance += amount;
The addInterest method calculates the monthly
interest and adds it to the account balance.
public void addInterest()
// Get the monthly interest rate.
// Calculate the last amount of interest earned.
// Add the interest to the balance.
interest = balance * (interest/12);
interest = intEarned;
balance += interest;
The getBalance method returns the account balance.
@return The account balance.
public double getBalance()
return balance;
The getInterestRate method returns the annual
interest rate.
@return The annual interest rate.
public double getInterestRate()
return interest;
The getLastInterest method returns the last amount
of interest earned.
@return The last amount of interest earned.
public double getLastInterest()
return intEarned;
import java.util.Scanner;
import java.text.DecimalFormat;
public class SavingsAccountTest
public static void main(String args[])
// Annual interest rate
double intRate;
// Starting balance
double balance;
// Amount of deposits for a month
double deposit;
// Amount withdrawn in a month
double withdraw;
// Interest earned
double intEarned = 0;
// Deposit accumulator
deposit = 0.0;
// Withdrawal accumulator
withdraw =0.0;
// Months that have passed
double months;
// Create a Scanner object for keyboard input.
Scanner keyboard = new Scanner(System.in);
// Get the starting balance.
System.out.println("What is your account's starting balance");
balance = keyboard.nextDouble();
if (balance < 0)
balance=0;
// Get the annual interest rate.
System.out.println("What is the annual interest rate?");
intRate = keyboard.nextDouble();
if (intRate <= 0 )
intRate = 0;
// Create a SavingsAccount object. Cannot find Symbol!!
SavingsAccount account = new SavingsAccount(balance,intRate);
// Get the number of months that have passed.
System.out.println("How many months have passed since the " +
"account has opened? ");
months = keyboard.nextDouble();
if (months <= 0)
months = 1;
// Get the deposits and withdrawals for each month.
for (int i = 1; i <= months; i++)
// Get the deposits.
System.out.println("Enter the amount deposited during month " + i);
deposit= keyboard.nextDouble();
account.deposit(deposit);
if (deposit <=0)
deposit = 0;
// Get the withdrawals.
System.out.println("Enter the amount withdrawn during month " + i);
withdraw = keyboard.nextDouble();
account.withdraw(withdraw);
if (withdraw <= 0 || withdraw >= balance)
withdraw = 0;
// Add the deposits to the account.
account.deposit(balance);
// Subtract the withdrawals.
account.withdraw(balance);
// Add the monthly interest.
account.addInterest();
// Accumulate the amount of interest earned. ????? Wrong
intRate += intEarned;
// Create a DecimalFormat object for formatting output.
DecimalFormat dollar = new DecimalFormat("#,##0.00");
// Display the totals and the balance.
System.out.println("Total deposited: " + dollar.format(account.deposit(balance)));
System.out.println("Total withdrawn: " + dollar.format(account.withdraw(balance)));
System.out.println("Total interest earned: " + dollar.format(account.addInterest()));
System.out.println("Account balance: " + dollar.format(account.getBalance()));
}
Maybe you are looking for
-
Hi experts, I copy one standard <b>Smart forms</b> namely LE_SHP_DELNOTE and did some changes and using NACE transaction i change one output type to that forms. But it gives an error message that 'Output could not be issued'. What is the problems. Pl
-
Access address book on iphone without syncing?
The screen has stopped working on my girlfriends iphone and she needs to access her contacts before it's replaced tomorrow, is there a way of accessing the address book without having to sync it to my computer as her mac is at home? I dont want to ha
-
Where is Adobe Creative Suite 5 Design Premium Korean Language version?
Where is Adobe Creative Suite 5 Design Premium Korean Language version? Please... I don't contact Adobe member to other method of phone, site, etc... my original DVD error, not reading data, so not install.
-
Using webservices in EP (jspDynPage)
Hi All in my portal Application (jspDyn page ) i need to access webservices How can i do this if i get any sample code it will be very helpful Please he me Thanks
-
I can't play apple trailers on my macbook pro
I keep getting this when i try to play trailers on apple site..my computer has quicktime player - this only recently started happening - what's going on?