Calculate Average value based on Day ??
Hello,
I am trying to calculate the Average value based on a day. The data is presented as follows...
Day SOCount
Mon 34
Mon 56
Mon 67
Tues 24
Tues 25
Tues 23
Weds 45
Weds 69
The issue im having is that the Day column needs to be grouped first and the SOCount sumed together. Then the Average SO Count needs to be calculate based on this.
Thanks
Thanks for the reply,
The solution you have provided only gives me the average of the count of the SO Count, not the actual average of all the values added together then divided by the count..
The report i am creating only has charts in it. So i am trying to create a chart showing the
Average Sale Order Value by day.
I should have metioned this from the start, sorry.
Is it possible to do ?
Edited by: davitali on Nov 4, 2011 6:32 AM
Similar Messages
-
Average the value based on day in SQL
I have a table with two fields (SampleTime, value) the table likes:
SampleTime field2
1999-01-01 01:00:00 0.01
1999-01-01 02:00:00 0.01
1999-01-01 03:00:00 0.03
The sample time has one hour interval. How can get average value of field2 based on day? like:
1999-01-01 average of all values within 1/1/99
1999-01-02 average of all values within 1/2/99
1999-01-03 average of all values within 1/3/99
Is there a build-in function in SQL to implement this? It should be very sample. But I am not sure how to write this SQL query statement. Thanks.Can explain the parameters : varchar(8), sampletime, 10?
What do these parameters mean?
Thanks.
you wanted the date in mm/dd/yy format... convert(varchar(8),sampletime,10) gets you the output in that format..
you did not mention your sql version, if sql 2008 and above, you can use date funtion(it the format does not matter).
declare @table table (SampleTime datetime,field2 decimal(3,2))
insert into @table
values
('1999-01-01 01:00:00','0.01'),
('1999-01-01 02:00:00','0.01'),
('1999-01-01 03:00:00','0.03')
select avg(Field2),Convert(varchar(8),sampletime,10) from @table group by Convert(varchar(8),sampletime,10)
--SQL 2008 and above
select avg(Field2),Cast(sampletime as date) from @table group by Cast(sampletime as date)
Hope it Helps!! -
Creating function to calculate average value
Hi,
The below query was successfully return an average value. It returned 1 row.
SELECT AVG(Volume)
FROM security
WHERE
Type = 'Future' AND
Rating = 'AAA' AND
Code = 1 AND
(Day = ''14-mar-09' OR
Day = '16-mar-09' OR
Day = '');
I tried to use that function on my created function below.
CREATE OR REPLACE FUNCTION fn_Vol_Average
( v_DayLast_1_Week IN DATE,
v_DayLast_2_Week IN DATE,
v_DayLast_3_Week IN DATE )
RETURN NUMBER IS
v_Vol_Average NUMBER;
BEGIN
SELECT AVG(Volume) INTO v_Vol_Average
FROM security
WHERE
Type = 'Future' AND
Rating = 'AAA' AND
Code = 1 AND
(Day = v_DayLast_1_Week OR
Day = v_DayLast_2_Week OR
Day = v_DayLast_3_Week);
RETURN NVL(v_Vol_Average, NULL);
END;
I called that function by the following query. it was work, however it return the whole rows. It looks like the function perform the average calculation of each rows on the table.
Can anyone help me what is going on with the logic?
select fn_Vol_average('14-mar-09','16-mar-09','')
from security
--But since your function calculates the average over the whole security table, you wouldn't call this from a select statement which also reads the security table.
You just want to execute it once.
declare
l_vol_average number;
begin
l_vol_average := fn_Vol_average('14-mar-09','16-mar-09','');
dbms_output.put_line(l_vol_average);
end;By the way, be careful with your date parameters. You should use TO_DATE with a proper format mask to prevent conversion errors. -
How to calculate average value?
Hi all,
I'm using Lumira 1.15. I'm doing some practices with the sample dataset BestRunCorp... I want to calculate the average value of gross margin which is grouped by lines so that I can use a line chart to show the difference between the gross margin value and average value.
How can I achieve this ?
Best regards,
ShuangIt looks like it calculates the average based on the dimension
See below:
If you take the "Best run" Excel file, sort by country, calculate the average in Excel, it matches Lumira's 4,056 (for Argentina)
I am not sure I follow your divide by 12 logic? -
Script logic to calculate average value on nodes - SAP BPC NW 10.0
Hi experts,
I need to have in the parent members of the dimension TIME (2014.Q1, 2014.Q2, 2014.Q3, 2014.Q4, 2014.TOTAL) the average value of their children and not the sum. For example :
2014.01 2014.02 2014.03 2014.Q1
1 2 3 2
2 = AVG(1, 2, 3)
I tried the script bellow but it doesn't work , it throws the error " ReferenceError : AVG is not defined"
*SELECT(%TIMESET%,"[ID]",TIME,"[CALC]='Y'")
*XDIM_MEMBERSET TIME = %TIMESET%
*XDIM_MEMBERSET MEASURES = PERIODIC
*WHEN DIM1
*IS C02
*WHEN TIME
*IS %TIMESET%
*REC(EXPRESSION = AVG(Descendants([%TIMESET%].CURRENTMEMBER)), TIME = %TIMESET%)
*ENDWHEN
*ENDWHEN
*COMMIT
How can I achieve this ?
Thanks
MahaThe best way is to enter 2 accounts: Productivity and Area, calculating by dimension member formula:
ProductivityPerHectare=IIF([Area]=0,NULL,[Productivity]/[Area])
If you have to enter ProductivityPerHectare and Area, then in script you can calculate Productivity:
*WHEN ACCOUNT
*IS Area
*REC(EXPRESSION=%VALUE%*[ACCOUNT].[ProductivityPerHectare],ACCOUNT=Productivity)
*ENDWHEN
*WHEN ACCOUNT
*IS ProductivityPerHectare //user input
*REC(EXPRESSION=%VALUE%*[ACCOUNT].[Area],ACCOUNT=Productivity)
*ENDWHEN
Then dimension member formula:
ProductivityPerHectareCalc=IIF([Area]=0,NULL,[Productivity]/[Area])
You can use arithmetic average of ProductivityPerHectare only if Area is always constant.
In this case you can create some dummy account member DUMMY and fill it with 1:
*WHEN ACCOUNT
*IS ProductivityPerHectare //user input
*REC(EXPRESSION=1,ACCOUNT=DUMMY)
*ENDWHEN
Then dimension member formula:
ProductivityPerHectareCalc=IIF([DUMMY]=0,NULL,[ProductivityPerHectare]/[DUMMY])
Vadim -
How to calculate acquisition value for specified day
Hi,
in my z program I have a problem how to calculate acquisition value for my asset for specified day.
Example:
I have asset created 8.7.2008 with TTYPE 104 (External asset acquisition) with value 5950.
30.11.2008 there is another TTYPE 272 (Retirement of current-yr acquis., w/o revenue) with value 950.
So BEFORE 30.11.2008 acquisition value is 5950. After is 5000. Is there any function module (or something else) in SAP system where I can send asset number and date a it return to me acquisition value for that day?
Many thanks for any answer!Hi,
your suggestion means that I have to compute acquisition value by myself (sum all TTYPE 1** - sum all TTYPE 2**). So SAP does't provide such functionality (LDB ADA have it, because it can compute acquisitiob value for specific day)?
Mant thanks for answer -
Read-in CSV and Calculate Average Value
I've got a csv file which I'm reading in but need to calculate the average value of the second column (CPU). It's in the following format:
Date CPU
01/09/2014 25.3
02/09/2014 22.3
03/09/2014 26.2
04/09/2014 22.1
I basically need the average CPU for the month. Any advice?
Thanks in advance
Adam"Date","CPU"
"01/09/2014","25.3"
"02/09/2014","22.3"
"03/09/2014","26.2"
"04/09/2014","22.1"
'@ | sc test.csv
(Import-Csv test.csv | measure CPU -Average).Average
23.975
[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " " -
How to calculate Average value stock value - MC.B
Hi All,
When we execute T code MC.B we get material analysis report . In it we have a column AVG VAL STOCK VALUE.
Can some one explain how it is calculated. I see the formula
The average stock value of the valuated stock is calculated using the formula:
beginning stock value + n stock value at month´s end
n + 1
Can Some one explain how it is calculated and what 'N' stands for?
Thanks,
Vengal Rao.MC.B is inventory turnover.
In the selection screen you enter how many periods to analyze.
by default it is today 06/11 to 08/11
n is the number of periods
so you have a beginning stock of period 06/11
+ end stock of period 06/11
+ end stock of period 07/11
+ end stock of period 08/11 (which is todays stock)
so the formula is:
beginning stock value + 3 stock value at month´s end
3 + 1 -
How to calculate a value, based on value from popup menu?
I'm creating an estimate worksheet. In one cell, I have a popup menu containing service codes such as "DIS", "SP", "AD" and so on. Based on the selected service code from the popup menu, I would like for the next cell to display the correct rate for that service. For example, if "DIS" was selected, I would like the Rate to apeear as $110. If "AD" was selected, I would like the Rate to show up as $150.
Thanks in advance,
TonyYou can create another reference table with your service code and cost. Then in the main table use the VLOOKUP formula to refer to the reference table and return the costs.
Example:
Table 2 (Reference Table)
_ A ______B
1 Code ___Cost
2 DIS _____$ 100
3 SP _____$ 125
4 AD _____$ 150
Main Table
_A ________ B
1 DIS _______=VLOOKUP(A1,Table 2 :: $A$1:$B$3,2,FALSE)
etc,
etc,
Regards, -
I need help writing a rule to calculate average units. I know the HFM admin documentation contains an Average Function, but my calculation needs to be a little different. I need to dynamically calculate average units based on the POV. Also, I need to always use "Beginning Units" in my calculation. I've listed some examples below...
1.) Periodic AvgUnits for May 2008 = (Apr 08 Units + May 08 Units) / 2
2.) QTD AvgUnits for May 2008 = (Mar 08 Units + Apr 08 Units + May 08 Units) / 3
3.) YTD AvgUnits for May 2008 = (Dec 07 Units + Jan 08 Units + Feb 08 Units + Mar 08 Units + Apr 08 Units + May 08 Units) / 6
Does anyone have any sugestions?
Thanks,
ClintYou need to use 3 different formulas here are some examples, you can derive the quarterly from this two:
Function Avg2(Acct)
Avg2 = "(" & Acct & " + " & Acct & ".P#Prior) / 2"
End Function
Function AccumYTD(Acct,pov_period)
AccumYTD = "(" & Acct
Select Case pov_period
Case 1
AccumYTD = AccumYTD & " ) "
Case 2
AccumYTD = AccumYTD & " + " & Acct & ".P#CUR-1 ) "
Case else
For PastMonth = 1 to pov_period - 1
AccumYTD = AccumYTD & " + " & Acct & ".P#CUR-" & PastMonth
Next ' PastMonth
AccumYTD = AccumYTD & " ) "
End Select ' Case pov_period
End Function -
I am trying to calculate Deviation Measure for the Reports and the formula to calculate is –
(average(last 7 days count ) – today’s count/100 )*10
Problem here is to calculate average for last 7 days .
I am using moving average but if I apply a filter , Moving average is calculated for the number of rows displayed whereas I want it for the number of days.
Formula for Moving average is - MAVG(Row Count,n) where n is number of rows displayed and not number of days. Is there any possible way to do it.(average(last 7 days count ) – today’s count/100 )*10
Filter( avg(col1) using date > current_date-7)) --Average for last 7 days
Filter(count(col) using date = current_date) - today's value -
Hi,
I have a problem. I'm reading data continuously from analog input. I want calculate average value when I press button START. Average value should be calculated from samples which are defined by 'Number of samples' and 'millisecond multiple'. When all samples are read, average vale should show.
The problem is that when number of samples is higher then 10, it doesn't work.
Can someone tell me what I did wrong?
Thanks
P.S.. I saw that there was something like this but I can't open it because I use Labview 8.5
Attachments:
Average.vi 35 KBFor that you need to store the previous value for averaging... i have attached a VI regarding that ( sorry no time to cleanup ).. You can use the logic to calculate the average of the samples (Still am not clear about you requirement).
The best solution is the one you find it by yourself
Attachments:
Average_anand.vi 26 KB -
How to calculate average if some of measure values are 0
Hi
I created a webI report on top of a Bex query, I have a more than 10 different measure in WebI report column on which i need to calculate average.
If I use the Average function provided with in WebI report it is calculating average for the measures which are having 0 values too, but i need to calculate average on a column only for those values which are not 0
Ex: Measure Quantity has values in the report like
100
100
0
100
100
Average function is calculating as 400/5
but I need 400/4, because one of the value is 0, so i need to avoid that count which is zero and should divide it by 4 but not 5.
One way is to custom create measure for all measures and make a if else condition and divided by that custom measure, but is there any other procedure?i hope this can help
=Average([myMeasure]) Where ([myMesyre] <> 0)
good luck
Amr
before the 0 add <> not Equal too sign < and >
Edited by: Amr Salem on Jan 19, 2011 9:29 AM
Edited by: Amr Salem on Jan 19, 2011 9:30 AM -
the data I measured changed rapidly, so i want get the average value of the data
Do not tell me to use mean.vi , i have already know that.
and i got an idea which is add the data into an array every time, then sum of all the data value and take the result divide by the number of elements
but i dont know how to achieve that, anyone can build a simple vi to show me ? thank you
i have attached my vi which is using mean.vi to calc the average value, you can delete it and using in your way , thank you !
Solved!
Go to Solution.
Attachments:
EN-new.vi 274 KBHi I got a similar issue for averaging. I used the mean.vi from the math function but the average is rolling when i run it. I am trying to calculate the average for the data i read to the RT FIFO (which is around 40000 lines).I got the writing part working, however, when i am reading the data, I couldn't get it working. I thought i read the data as a 1-D array, and then pass it to the Mean.vi and then got the result. But seems like the mean is only showing the last data in the array.
Can someone help me with this??
Attachments:
FPGA-vi.png 242 KB
RT-vi.png 182 KB
RT-2mod.vi 515 KB -
Script Logic to Calculate average or sum based on parent member involving
Hi ! freinds,
I am trying to write script logic to calclate
sum of previous 2 months for one group account having 100 childrens and write to DIFFERENT INPUT ACCOUNT . Please suggest the best practive to calculate the value.
I tried with : *WHEN *IS / *ENDWHEN its is not possible to define
when ACCT
is BAS(Group Account)----
NOT SUPPORTED
Rec .....
ENDWHEN
Please helpVishwanath,
Are you trying to calculate an average by account for the two months or an average of all accounts?
Ex 1
Feb Mar Avg
acct1 1000 500 750
acct2 1000 1000 1000
Ex2
Feb Mar
acct1 1000 500
acct2 1000 1000
Avg 1000 750
Akos
Maybe you are looking for
-
Sync just flagged photos to iphone?
When I click on the photo tabs in itunes to sync photos to my phone I see events, places, people, etc, but how I can just sync photos I flagged to my phone? I don't understand why they don't just have a box there you can check. It has boxes for almos
-
Firmware file not found! help!
Have an ipod video which works but when i try and update it itunes says it cannot find the file. what can i do? video Windows XP
-
Find all images that have no Keyword assigned?
Is it possible to create a smart album to show all the pictures WITHOUT a keyword? When I create the smart folder and click Keywords, the only options are "contain one or more of the following" and "contain all of the following".
-
Starting from outlook link Firefox is a tiny little sqare in left upper corner
In this update from 5.0 to 7.0 I hate .o versions, said that net frame 1.0 was invalid and was updating to 1.3.1 which never finished, I killed after an hour, and now have no net frame but a gray one. I was lead to net frame 3.5 SP1 which I already h
-
Firefox crashed and I have been unable to restart it. Sent Report by email to Firefox two weeks ago no response. At this point I want to uninstall first and then new install.