Average of a subset of data

Post Author: squishy
CA Forum: Formula
I need to find a way to get the average of a subset of data
in a report.
For example
The datasource returns:
User        
Month          Current       
Bob           mar                10               
Janet         mar                  5                 
James        mar                 24               
Bob           feb                12               
Janet         feb                  4                
James        feb                 22               
Bob           Jan                14               
Janet         Jan                  3                 
James        Jan                 30            
I need  the report to
show in addition to the current value for march for each user, the average of
the previous two months
So the report would actually show:
User        
Month          Current        Average
Bob           mar                10                13
Janet         mar                  5                  3.5
James        mar                 24                26
Is there a way to get crystal to calculate the average for
the previous two months for each user?

Brad
The calculations are for Emission calculations for vehicles.  The main input data set is a second-by-second file containing many channels / groups. For a number of the raw channels (eg distance) the raw data is first integrated and then analyzed into a series of windows
oDistanceWindow(iLoop)  = ODistanceInt(iPos) - ODistanceInt(iLoop)
Each window is defined by a start (iloop) and end index (ipos) referencing.Each result is then added to an output group.
However my problem is I want  to calculate a statistical parameter for each of these sub-groups of data and generate an output group with these results. An example being the mean speed. This is not a good example since this can be calcuated easily by dividing the distance and time already being calculated.
I hope this helps
David

Similar Messages

  • How do you find the average value of all the data between two points on a single channel

    I am tring to calculate the average value of all the data points on a single plot between two seperate points
    I have attahced an illustration.
    Tim
    Solved!
    Go to Solution.
    Attachments:
    plot.jpg ‏173 KB

    Hey smoothdurban,
    I've seen Brad's code, and trust me, it's worth the effort to let him help you get it up and running - it's definitely the most ideal way to solve this problem.  However, as Brad said, there are multiple ways to tackle this - both interactive and programmatic - so in the meantime, I'll take a second to detail one of the interactive and sure-fire ways to find the average of data between two points on a single channel.
    We'll use"Flags."  Set up your VIEW graph exactly as you did on your original screenshot, using Band Cursors to approximate the beginning and ending X-values representing the range you want to examine.  Next:
    1. Click the "Set Flags" button () that is a part of your 2D Axis System.  Note that you can hold down the Shift button if you ever decide you want to do this on more than a single curve at one time.
    2. Select the "Flags: Copy Data Points" button that enables after Flags are set.
    3. This creates new channel(s) in the default (bold) group in the Data Portal that contains only the Flagged data.
    4. Select DIAdem ANALYSIS.
    5. Select Statistics » Descriptive Statistics.
    6. In the Channels input, select the newly created channel containing your Flagged Y-Data.
    7. Ensure that the Arithmetic Mean parameter is set.  You can preview the data and the result in the dialog before pressing OK to execute the calculation. 
    You may have noticed that in the Descriptive Statistics calculation, one of the parameters that you can set is the range of channel rows to operate on - so, if you know the row numbers of your beginning and ending X-values, you could just simply run the Descriptive Statistics calculation and use this parameter to operate on a row subset of your original channel instead of the entire channel.
    Derrick S.
    Product Manager
    NI DIAdem
    National Instruments

  • How to move only subset of data from one database to another?

    Both source & destination are Oracle11g databases.
    The requirement details are as below,
    1) The database contains static as well as transactional data for telecom domain.
    2) We have to move region-wise data from one database to another.
    3) There are around 10 regions.
    4) The region wise data extraction from source db is based on around 40 to 50 tables. Rest of the tables contains
    static data & it will not change.
    5) The volume is around 1 million subscribers per region.
    6) The migration is required because
    a) The client is upgrading its base product which uses this database
    b) There is a change in structure of static tables
    c) Hardware upgrade
    d) The client want to start with single region on new database & rest of the regions will be operated from old
    database.
    7) Keep execution time to very minimum.
    I am thinking to have solution as below,
    1) Create destination database with upgraded db structure (as mentioned in 6b)
    2) Create database links to access source db in destination db.
    3) Write SQL queries to fetch data from all the respective tables for a specific region
    4) Write separate PL/SQL blocks for each table to fetch data from source db & insert into respective table in
    destination db
    a) Use FOR ALL & bulk collect to improve the performance
    b) Divide table data into multiple chunks & execute parallel batches (around 10) to insert the data
    5) Validate pre & post counts to verify the success of migration
    Is there any other better way?
    Regards,
    Sandeep

    How to move only subset of data from a partiular table by using transportable tablespace?
    E.g. SUB table using SMP_SUB tablespace contains subscriber data in source database.
    The indexes defined on SUB table are under SMP_IDX_SUB tablespace
    The subscribers data can be categorized by different regions, say region_id column. Then how to move data & indexes of SUB table from source db to destination db?
    any specific example would be helpful.

  • What is the Best way to extract a subset of data from a Production database

    Hi,
    One of our cleint want to to extract a subset of data from a Production databases in order to build a dev or test database. Since it is a banking sector they do not want to clone the db.
    Can anybdoy suggests any tool or any info
    Regards
    Manoj

    DataBee is one option. Depending on circumstances, you may also want their DataMasker utility in addition...
    Of course, depending on your particular system and your particular requirements, this sort of thing can rather quickly get quite complicated since you may need very particular types of subsets of data...
    Justin

  • RMAN clone - only subset of data

    I have a requirement to clone the Production to Test database with the minimum size (subset of data).
    Can some one help me how to extract only subset of data from prod ?

    You could consider using SKIP TABLESPACE with the RMAN DUPLICATE command to create a test database that is a subset of the production, but it may depend on what you mean by "subset" of data.

  • How can I open a tdms file and replace a subset of data then save that change without re-writing the entire file again?

    Hi all,
    Is it possible to open a tdms file and make a small change an an array subset then save the file without having to save the whole dataset as a different file with a new name? That is to say, is there something similar to "Save" in MS Word rather than "Save As"... I only want to change a 1D array of four data points in a file of 7M data points.
    I am not sure if this make sense? Any help is apreciated.
    Thanks,
    Jack

    You can use either one, but for your application, I would use the synchronous.  It requires far less setup.  When you open the file, set both enable asynchronous and disable buffering to FALSE to enable you to use synchronous with arbitrary data sizes.
    Attached code is LabVIEW 2011.
    This account is no longer active. Contact ShadesOfGray for current posts and information.
    Attachments:
    UpdateTDMS.zip ‏20 KB

  • Returning Random Row based on Subset of Data within Table

    Hi,
    Please see below.  Running SQL Server 2008 R2.
    Sample DDL:
    CREATE TABLE [dbo].[TestPersons]
    [TestPersonID] [int] NOT NULL IDENTITY(1,1),
    [FirstName] [varchar](50) NULL,
    [LastName] [varchar](50) NULL,
    [AreaID] [varchar](50) NULL,
    CONSTRAINT [PK_TestPersons_TestPersonID] PRIMARY KEY CLUSTERED ([TestPersonID] ASC)
    WITH
    PAD_INDEX = OFF,
    STATISTICS_NORECOMPUTE = OFF,
    IGNORE_DUP_KEY = OFF,
    ALLOW_ROW_LOCKS = ON,
    ALLOW_PAGE_LOCKS = ON
    ON [PRIMARY]
    ON [PRIMARY]
    GO
    Sample Data:
    INSERT INTO
    [dbo].[TestPersons] ([FirstName], [LastName], [AreaID])
    VALUES
    ('Carlos', 'Matlock', 'A0009'),
    ('William', 'Rivas', 'A0001'),
    ('Kathryn', 'Rice', 'A0008'),
    ('John', 'Ball', 'A0009'),
    ('Robert', 'Barnhill', 'A0009'),
    ('Timothy', 'Stein', 'A0009'),
    ('Christopher', 'Smith', 'A0001'),
    ('Brian', 'Speakman', 'A0001'),
    ('Harold', 'Clark', 'A0009'),
    ('Tim', 'Henson', 'A0009'),
    ('Victor', 'Chilson', 'A0009')
    The above insert statement is a small example of the data contained in this table.  Normally the table would contain several thousand rows.  We use the following query to replace actual data with random rows from our test table:
    UPDATE
    [P]
    SET
    [P].[FirstName] = [T].[FirstName],
    [P].[LastName] = [T].[LastName],
    [P].[AreaID] = [T].[AreaID]
    FROM
    [dbo].[Persons] [P]
    INNER LOOP JOIN
    [dbo].[TestPersons] [T] ON ([T].[TestPersonID] = (1 + ABS(CRYPT_GEN_RANDOM(8)%5000)))
    This query works as it selects a random row from the entire set of data in the table.  However there are cases where we need to specify a restricted subset to randomize from.  For example, we may need to randomize data only for Persons with an AreaID
    of A0001 or A0008.  So in that case, and using the sample data above, we would want the  randomization to only select from rows in TestPersons that have an AreaID of A0001 or A0008.  How would I go about accomplishing this?  I've tried
    adding a WHERE clause but it seems it's ignored because of the INNER LOOP JOIN.  I've also tried including [P].[AreaID] = [T].[AreaID] in the join hint but to no avail.
    I also realize having sample data with only the set that we need would solve this problem but for our needs we need a large test set as our randomization requirements depend on the situation.
    Any assistance is greatly appreciated!
    Best Regards
    Brad

    DECLARE @TestPersons TABLE (TestPersonID int NOT NULL IDENTITY(1,1), FirstName varchar(50), LastName varchar(50), AreaID varchar(50))
    INSERT INTO @TestPersons (FirstName, LastName, AreaID)
    VALUES ('Carlos', 'Matlock', 'A0009'), ('William', 'Rivas', 'A0001'), ('Kathryn', 'Rice', 'A0008'), ('John', 'Ball', 'A0009'), ('Robert', 'Barnhill', 'A0009'), ('Timothy', 'Stein', 'A0009'),
    ('Christopher', 'Smith', 'A0001'), ('Brian', 'Speakman', 'A0001'), ('Harold', 'Clark', 'A0009'), ('Tim', 'Henson', 'A0009'), ('Victor', 'Chilson', 'A0009')
    ;WITH subset AS (
    SELECT ROW_NUMBER() OVER (ORDER BY TestPersonID) AS sID, *
    FROM @TestPersons
    WHERE FirstName LIKE '%e%'
    SELECT *
    FROM subset
    WHERE sID = round((((SELECT COUNT(*) FROM subset) - 1 - 1)*rand())+1,0)
    This will grab a random row from a subset (defined in the CTE).

  • Filtering and calculating averages of array subsets

    I've got a 2-D array coming out of a loop and I need to calculate average for subsets corresponding to iterations 0-9, 10-19, etc..  Additionally, I need to filter out values above and below acceptable limits before calculating average.  Any suggestions for how to approach this?
    Solved!
    Go to Solution.

    My suggestion is to slog through each array subset, use a for loop to add up the values you want, keep track of the number of values, then divide out for the average. 
    Every tenth reading you could clear the sum and counts.
    The results would be saved in an array that only adds a value every tenth loop.
    You could keep track of the one to ten value separately from the number of values accepted ( a.k.a. Filtering).
    So my slog suggestion would be a for loop, two counters ( # accepted values and one to ten count), an array to store the averages and a numeric to hold the sum.
    The filter criteria would produce a Boolean that would toggle adding to the sum and adding to the # accepted values.
    The Sum and the counters need to be shift registers, and as I mentioned, there would be some logic to clear these shift registers every time the 'one to ten' count got to ten
    Mark Ramsdale

  • How to estimate average row size without populating data

    hi all
    I have a work of estimating the average row size of some tables. Because I don't want to populate these tables with data(It's alot work to do it),so I am not able to get the arerage row size from dba_tables by analyzing these tables.
    Is there other way around to do my job easily?
    Thanks alot.

    Hi,
    I am not a coder,I am a DBA.Do you think that it's coder's responsibility to do such kind of works?Still i think it part of the dba role to suppport the developers or to provide guidance, the easiet way would be the using package DBMs_SPACE, perhaps if you take the help of developer, ask him to populate the single record with full length or say max length in each table and generate the 10053 trace with basic select clauses, You can the information from the trace too...
    - Pavan Kumar N

  • Average of a field by date by site

    Our data source has multiple records for a single day (date time stamped) for multiple sites.
    For example:
    SiteID, Date, Time, CH4
    With a record every few minutes.
    We need to calculate the average of CH4 for a single day (Date) for each Site (SiteID). The following CTE gets me the most recent value:
    WITH GasEngine_CTE 
    AS
    SELECT CH4, ROW_NUMBER() OVER(PARTITION BY SiteID ORDER BY CAST([Date] AS DATETIME) + CAST([Time] AS DATETIME) DESC) RowNumber
    FROM dbo.GasEngine
    SELECT *
    FROM GasEngine_CTE 
    WHERE RowNumber = 1
    I need to modify to retrieve the average for each day and each site. I think I need to group (partition) by SiteID and [Date]

    Is that you are looking for?
    declare @gasengine table(ch4 int, site varchar(2), dt date);
    insert into @gasengine
    values(1,'S1',getdate()),
    (3,'S1',getdate()),
    (3,'S1',getdate()-1),
    (5,'S1',getdate()-1);
    SELECT Site,dt,Avg(CH4)
    FROM @gasengine
    group by [Site],[Dt]
    Satheesh
    My Blog |
    How to ask questions in technical forum

  • How do I calculate an average of a section of data from one channel

    I want to be able to:
    - plot some data in VIEW
    - zoom in on a section of a channel of interest (lets say zoom in on 10 seconds of pressure data from a 10 minute log)
    - calculate an average of the data that falls in that zoomed time range, i.e. calculate the 'local' average of that 10 seconds worth of my pressure data

    Hi David,
    In order to link in your data instead of the example data, you will need to edit the script associated with that example.  In the example finder, if you select the "Copy example files" option under "Start example," then you can copy the necessary files to a different location and then load them into the script window of DIAdem.  You can then edit the file and path information i nthe VIEW_Statistic_Init.vbs file.
    You can also add a menu command to run this script to your DIAdem interface.  You will need to use the MenuItemAdd command to do so.  You can read more about the command in the DIAdem Help:
    Hope this helps!
    Regards,
    Stephanie R.
    National Instruments
    Stephanie R.
    National Instruments

  • Exporting subset of data

    In MapPoint I was able to import an excel file with a series of data attached to a pushpin with Lat and Long. Then I could draw a border around a subset of that data and export to an excel file. Is that function available in Streets and Trips?

    Hello,
    You should ask in the
    Streets and Trips forum.
    Karl
    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
    My Blog:http://unlockpowershell.wordpress.com
    My Book:Windows PowerShell 2.0 Bible
    My E-mail: -join ('6F6C646B61726C40686F746D61696C2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})

  • How do i create a subset of data in numbers 3.5

    Hi
    I use Numbers 3.5.2 on my MacBook Pro. I am familiar with Excel but finding it difficult to transfer my Pivot Table knowledge into Numbers. I just about understand how SUMIF works now but have a further question related to summarising data from one table into another table and would very much appreciate some guidance as I can't find any tutorials covering this subject.
    Example
    Assume Table 1 has a column of data called Surname and another called Pay.
    Table 1 has 100 rows and there are 20 unique entries for Surname.
    I want to summarise the Table 1 data into Table 2 by Name by Pay.
    But I don't want to manually input all the unique entries of Surname into Table 2.
    I want to create a column called Surname in Table 2 that holds 1 row for each unique Surname in Table 1.
    So Table 2 would have 20 rows.
    I will then use SUMIF to total all Pay for each Surname now in Table 2 by referencing Pay from Table 1.
    It would be great if rows in Table 2 were created automatically when entering a row in Table 1 (assuming it's the first row in Table 1 with that specific Surname) but that's not absolutely essential if it's complex.
    I do have a further question relating to this but any help to get me to understand how to effectively extract the 20 entries of Surname from Table 1 into Table 2 would be tremendous. In anticipation, thank you for reading.
    Regards
    Martin

    Hello
    For instance, you may try something like the following tables.
    Table 1 (excerpt)
    A1  Surname
    A2  A
    A3  B
    A4  A
    A5  A
    B1  Pay
    B2  10
    B3  20
    B4  20
    B5  10
    C1  ordinal
    C2  =COUNTIF(A$2:A2,A2)
    C3  =COUNTIF(A$2:A3,A3)
    C4  =COUNTIF(A$2:A4,A4)
    C5  =COUNTIF(A$2:A5,A5)
    Table 2 (excerpt)
    A1  Surname
    A2  =IFERROR(INDEX(Table 1::A,C2,1),"")
    A3  =IFERROR(INDEX(Table 1::A,C3,1),"")
    A4  =IFERROR(INDEX(Table 1::A,C4,1),"")
    A5  =IFERROR(INDEX(Table 1::A,C5,1),"")
    B1  Total Pay
    B2  =IF(A<>"",SUMIF(Table 1::A,A2,Table 1::B),"")
    B3  =IF(A<>"",SUMIF(Table 1::A,A3,Table 1::B),"")
    B4  =IF(A<>"",SUMIF(Table 1::A,A4,Table 1::B),"")
    B5  =IF(A<>"",SUMIF(Table 1::A,A5,Table 1::B),"")
    C1  index
    C2  =IFERROR(MATCH(1,Table 1::C,0),"")
    C3  =IFERROR(MATCH(1,OFFSET(Table 1::C,C2,0,ROWS(Table 1::C)-C2,1),0)+C2,"")
    C4  =IFERROR(MATCH(1,OFFSET(Table 1::C,C3,0,ROWS(Table 1::C)-C3,1),0)+C3,"")
    C5  =IFERROR(MATCH(1,OFFSET(Table 1::C,C4,0,ROWS(Table 1::C)-C4,1),0)+C4,"")
    Notes.
    Table 1::C is to record ordinal number per distinct name in Table 1::A.
    Table 2::C is to calculate row indices in Table 1::C where its value = 1, i.e., row indices of the 1st appearence of every distinct name in Table 1::A.
    Formula in Table 1::C2 can be filled down.
    Formula in Table 2::C3 can be filled down.
    Formulae in Table 2::A2 and Table 2::B2 can be filled down.
    Tables are built in Numbers v2.
    Hope this may help,
    H
    EDIT: fixed notes.

  • Display a subset of data?

    I have a data grid populated by an XMLList from an XML file.
    Currently, it displays data from the entire file.
    However, there is a node for each item in the list indicating
    a category, e.g. "Fruits", Vegetables"
    I want to have a toggle button bar with buttons "Fruits",
    "Vegetables" that when clicked update the datagrid display to only
    show records matching the term.
    How is this done? The book I bought (Friends of Ed) only
    showed the solution usinf ColdFusion, but I need to do it all in
    Flex. Thanks.

    I am not an expert but I have a set of radio buttons that
    need to filter data in a grid and I use a filter function like
    this;
    ----Where you load the datat associate a filter like
    this------
    acVendorDetail.filterFunction=grdVendorDetailFilter;
    ------ Here is the filter ---------
    public function grdVendorDetailFilter(item:Object):Boolean
    var result:Boolean=false;
    switch (rbtnStatus.selectedValue.toString().toUpperCase())
    case "ALL":
    result=true;
    break;
    case "CLEARED":
    if (item.CLEAR_DATE != null) result = true;
    break;
    case "UNCLEARED":
    if (item.CLEAR_DATE == null) result = true;
    break;
    return result;
    ---- In the clickevent of the radio button do this ------
    acVendorDetail.refresh();
    That is all there is to it...
    Paul

  • Seeing average minutes for year to date

    I would like to check and see how many minutes are used on average per month for the last year - is there anyway to do that online?

    Manually, yes.   Pull up each of your bills for the last year, find the total minutes, figure the average.
    A stat you can click and get easily?  I don't think so.

Maybe you are looking for

  • How to call print Quote functionality in istore

    Hi , We need to call template Print Quote functionality from istore, like print quote template in oracle quoting. Thanks, lsp .

  • UDF for reading a particular line and storing the value in a variable

    Hi Experts, I am reading entire file content in single feild in source data type.I want to write a UDF to seach for a particular pattern(say :25: and store the value after it i.e  34535764778 detination for further use). EX: My  sample file and its 

  • 2.2 SOFTWARE makes iphone worse

    I lose connection 70% of the time, to the point where i have to either turn off and on the phone. MY 3g/E connection, goes away for extensive periods of time. I probably have to reboot my phone 4-5times a day. And i just purchased this 3G Iphone 2wee

  • HT3939 How do i identify my iPhone is 4 or 4s

    I have iPhone 4 and 4S, but I cant diff b/w them, there is lot of ways to check the diff, but I want to know which model is this exactly, IS THERE ANY WAY TO FIND MY IPHONE MODEL?

  • IOS 5.0.1 will not download

    I keep trying to download and update my iphone 4 through iTunes to incorporate the iOS 5.0.1.  Every time I do try to do this an error comes up stating that I need to check the network because the network failed.  I tried to find a link for the iOS 5