Group based on row data

Given the following data:
id duration start date end date
1 15 08/01/2008 10:00 08/01/2008 10:15
2 15 08/01/2008 10:15 08/01/2008 10:30
3 15 08/01/2008 10:30 08/01/2008 10:45
4 15 08/01/2008 11:00 08/01/2008 11:15
5 15 08/01/2008 11:30 08/01/2008 11:45
6 15 08/01/2008 11:45 08/01/2008 12:00
7 15 08/01/2008 12:00 08/01/2008 12:15
Is it possible to group them based on the sum of the duration column? If three rows' duration sum equals 45 and the datetimes are contiguous, then they'll be grouped as 1. So in the example above, [1 2 3] will be grouped as one and [5 6 7] will be grouped as another - row 4 is excluded since row 4 and row 5 aren't contiguous.
Thanks.

How about:
SQL> alter session set nls_date_format = 'mm/dd/yyyy hh24:mi'
  2  /
Session altered.
SQL> with t1 as (
  2              select 1 id,15 duration,to_date('08/01/2008 10:00') start_date,to_date('08/01/2008 10:15') end_date from dual union all
  3              select 2, 15, to_date('08/01/2008 10:15'), to_date('08/01/2008 10:30') from dual union all
  4              select 3, 15, to_date('08/01/2008 10:30'), to_date('08/01/2008 10:45') from dual union all
  5              select 4, 15, to_date('08/01/2008 11:00'), to_date('08/01/2008 11:15') from dual union all
  6              select 5, 15, to_date('08/01/2008 11:30'), to_date('08/01/2008 11:45') from dual union all
  7              select 6, 15, to_date('08/01/2008 11:45'), to_date('08/01/2008 12:00') from dual union all
  8              select 7, 15, to_date('08/01/2008 12:00'), to_date('08/01/2008 12:15') from dual union all
  9              select 8, 45, to_date('08/01/2008 13:00'), to_date('08/01/2008 13:45') from dual union all
10              select 11, 15, to_date('09/02/2008 08:00'), to_date('09/02/2008 08:15') from dual union all
11              select 12, 15, to_date('09/02/2008 08:15'), to_date('09/02/2008 08:30') from dual union all
12              select 13, 15, to_date('09/02/2008 08:30'), to_date('09/02/2008 08:45') from dual union all
13              select 14, 15, to_date('09/02/2008 08:45'), to_date('09/02/2008 09:00') from dual union all
14              select 15, 15, to_date('09/02/2008 09:00'), to_date('09/02/2008 09:15') from dual union all
15              select 16, 15, to_date('09/02/2008 09:15'), to_date('09/02/2008 09:30') from dual union all
16              select 17, 15, to_date('09/02/2008 09:30'), to_date('09/02/2008 09:45') from dual union all
17              select 18, 15, to_date('09/02/2008 09:45'), to_date('09/02/2008 10:00') from dual union all
18              select 19, 15, to_date('09/02/2008 10:00'), to_date('09/02/2008 10:15') from dual union all
19              select 20, 15, to_date('09/02/2008 10:15'), to_date('09/02/2008 10:30') from dual union all
20              select 21, 30, to_date('09/02/2008 10:30'), to_date('09/02/2008 11:00') from dual union all
21              select 22, 15, to_date('09/02/2008 11:00'), to_date('09/02/2008 11:15') from dual
22             ),
23       t2 as (
24              select  id,
25                      duration,
26                      start_date,
27                      end_date,
28                      case
29                        when lead(start_date,1,end_date - 1) over(order by id) != end_date then 1
30                        when duration + lead(duration) over(order by id) > 45 then 1
31                        when lead(start_date,2,end_date - 1) over(order by id) != lead(end_date) over(order by id) then 2
32                        when duration + lead(duration) over(order by id) + lead(duration,2) over(order by id) > 45 then 2
33                        else 3
34                      end grp_size,
35                      case
36                        when lead(start_date,1,end_date - 1) over(order by id) != end_date then duration
37                        when duration + lead(duration) over(order by id) > 45 then duration
38                        when lead(start_date,2,end_date - 1) over(order by id) != lead(end_date) over(order by id) then duration + lead(duration) over(order by id)
39                        when duration + lead(duration) over(order by id) + lead(duration,2) over(order by id) > 45 then duration + lead(duration) over(order by id)
40                        else duration + lead(duration) over(order by id) + lead(duration,2) over(order by id)
41                      end grp_duration,
42                      row_number() over(order by id) rn
43                from  t1
44             ),
45       t3 as (
46              select  id,
47                      level grp_number,
48                      grp_duration
49                from  t2
50                start with id = 1
51                connect by rn = prior rn + prior grp_size
52             )
53  select     t1.*,
54          max(t3.grp_number) over(order by t1.id) grp_number,
55          last_value(t3.grp_duration ignore nulls) over(order by t1.id) grp_duration
56    from     t1,
57          t3
58    where t1.id = t3.id(+)
59    order by t1.id
60  /
        ID   DURATION START_DATE       END_DATE         GRP_NUMBER GRP_DURATION
         1         15 08/01/2008 10:00 08/01/2008 10:15          1           45
         2         15 08/01/2008 10:15 08/01/2008 10:30          1           45
         3         15 08/01/2008 10:30 08/01/2008 10:45          1           45
         4         15 08/01/2008 11:00 08/01/2008 11:15          2           15
         5         15 08/01/2008 11:30 08/01/2008 11:45          3           45
         6         15 08/01/2008 11:45 08/01/2008 12:00          3           45
         7         15 08/01/2008 12:00 08/01/2008 12:15          3           45
         8         45 08/01/2008 13:00 08/01/2008 13:45          4           45
        11         15 09/02/2008 08:00 09/02/2008 08:15          5           45
        12         15 09/02/2008 08:15 09/02/2008 08:30          5           45
        13         15 09/02/2008 08:30 09/02/2008 08:45          5           45
        ID   DURATION START_DATE       END_DATE         GRP_NUMBER GRP_DURATION
        14         15 09/02/2008 08:45 09/02/2008 09:00          6           45
        15         15 09/02/2008 09:00 09/02/2008 09:15          6           45
        16         15 09/02/2008 09:15 09/02/2008 09:30          6           45
        17         15 09/02/2008 09:30 09/02/2008 09:45          7           45
        18         15 09/02/2008 09:45 09/02/2008 10:00          7           45
        19         15 09/02/2008 10:00 09/02/2008 10:15          7           45
        20         15 09/02/2008 10:15 09/02/2008 10:30          8           45
        21         30 09/02/2008 10:30 09/02/2008 11:00          8           45
        22         15 09/02/2008 11:00 09/02/2008 11:15          9           15
20 rows selected.
SQL> SY.

Similar Messages

  • Create a group based on row count

    I am looking for a way of reducing the size of tables I am displaying in my monthly report, by counting some rows together, and naming them 'other'
    I would like to always show all rows, where count of item is >= 50, but all rows where count of item < 50, total up and call 'other'.  I will add an example image as soon as my account has been verified
    I can hide rows using this in the visibility =iif(Count(Fields!Item.Value) >= 50, False, True)
    I have duplicated the line, and added a filter to each (one for greater than 50, one for less than 50) but my totals are still counting all the data, and not just the filtered data.
    Ideally, I would like to add a column using something like =iif(Count(Fields!Item.Value) >= 50, "Over50", "Under50"), or a group based on the same sort of idea, but I keep getting errors about using aggregates in columns.
    Any suggestions?
    Cheers

    What you can do is to add derived column in query behind like this
    SELECT other columns...,
    CASE WHEN Cnt >= 50 THEN YourGroupingField ELSE 'Other' END AS GrpName
    FROM
    SELECT *,COUNT(1) OVER (PARTITION BY YourGroupingField) AS Cnt
    FROM Table
    )t
    Then in your reports use =Fields!GrpName.Value as the Grouping column and you will get required output
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Disable Table field cells based on Row Data

    Hi,
    Need to disable cells of a simple table based on a row level value. For example: if the column6 value for 3rd row is 'A' disable column2 for the 3rd row (No User entry can be made). This behaviour would be same for all rows having column6 as 'A'.
    Please advise.
    Thanks
    Anirban
    Edited by: user1580623 on Jun 29, 2009 6:31 AM

    Anirban,
    Please check the Switcher Bean. You need to associate an attribute to the Switcher. It would have multiple cases (items under them). Based on the value of the Switcher attribute appropriate Case is selected.
    In your VO you can write a decode logic to set the value of Switcher attribute based on the conditions. The selected case can have disabled items and hence you can get the behaviour of your choice.
    Regards
    Sumit

  • Set DataGridColumn editable based on row data

    I searched for this but did not find a direct answer. People wanted something similar but not exactly the same.
    I have several columns in a standard datagrid that I would like to set editable if the data.company_id > 0. Is this possible? Here's my MXML code:
    <mx:DataGridColumn headerText="Part Number"
                       dataField="part_number"
                       editable="false"
                       itemRenderer="controls.setTextColor"/>
    I tried:
    <mx:DataGridColumn headerText="Part Number"
                        dataField="part_number"
                        editable="{data.company_id > 0 ? true : false;}"
                        itemRenderer="controls.setTextColor"/>
    But of course that would be too easy, right?
    Help greatly appreciated...
    Rick

    But of course that would be too easy, right?
    aha, you're in luck
    Very quick and rough, but it works like a charm
    XML (written from php)
    <?php
         echo
         <thing>
              <edit>true</edit>
              <value>10</value>
         </thing>
         <thing>
              <edit>false</edit>
              <value>1000</value>
         </thing>
         <thing>
              <edit>false</edit>
              <value>550</value>
         </thing>
         <thing>
              <edit>true</edit>
              <value>20</value>
         </thing>
    ?>
    Flex
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="stuff.send()">
        <mx:HTTPService id="stuff" showBusyCursor="true" method="POST" url="http://localhost/stuff.php"/>
        <mx:DataGrid id="blah" x="240" y="93" dataProvider="{stuff.lastResult.thing}" editable="{blah.selectedItem.edit}">
            <mx:columns>
                <mx:DataGridColumn dataField="value" editable="{data.edit}"/>
            </mx:columns>
        </mx:DataGrid>
    </mx:Application>
    so yeah, i'd assume you'd have to edit the actually datagrid editable properties, rather than just the datagrid column. If your function doesn't work in there then just feed it a direct boolean value like i did.

  • Header row in ALV Grid, based on the data in the table

    Hi All,
    I have a requirement wherein, based on the data in the table used for ALV, i need to add rows as sort of header in the ALV display.
    For e.g. my table has
    Appl No.  Item  Material  Desc.           Cost                 -> Column Heading
    1             10     400        Excavation    10.00               -> Data
    1             20     400        Footing         10.00
    2             10     400        Excavation    10.00
    2             20     400        Footing         10.00
    For every new Appl No., i need to add a row, or sort of header specifying the appl no. details. means
    Appl No.  Item  Material  Desc.           Cost
    Appli. No. 1                   Date: 01/01/1009                   -> my requirement
    1             10     400        Excavation    10.00
    1             20     400        Footing         10.00
    Appli. No. 2                   Date: 02/01/1009
    2             10     400        Excavation    10.00
    2             20     400        Footing         10.00
    Is this possible in ALV my any means? Currently i m using normal ALV Grid
    Regards,
    Janaki

    Hi..
         Try like this... I think u have Application number and date in ur table ... First get the total table data into internal table.. and to add the row
         *Declare the var1 as 0 and var2.
    loop at internal table
         *var1 = var1 +1
    when application number =var1
             concatenate : 'Appli. No.' (table- appli no field) 'Date:'  (table-date field) into var2.
    perform display(some name)
         *endloop.
         *form display...
              alv display part.. first give that var2 like eg.. wa_alv-field= 'var2'.
    end form.
        Hope this will help u .....
    Regards,
    Abaper

  • Cursor and Update rows based on value/date

    SQL Server 2012
    Microsoft SQL Server Management Studio
    11.0.3128.0
    Microsoft Analysis Services Client Tools
    11.0.3128.0
    Microsoft Data Access Components (MDAC)
    6.1.7601.17514
    Microsoft MSXML 3.0 4.0 5.0 6.0 
    Microsoft Internet Explorer
    9.11.9600.16518
    Microsoft .NET Framework
    4.0.30319.18408
    Operating System
    6.1.7601
    The objective of this is to test the Cursor and use it on a production environment after this is fixed. What I would like to do is update rows in a column i duplicated originally called 'HiredDate' from AdventureWorks2012 HumanResources.Employee table. I
    made a duplicate column called 'DateToChange' and would like to change it based on a date I have picked, which returns normally 2 results (i.e. date is '04/07/2003'). The code runs but will not change both dates. It did run however with an error but changed
    only 1 of the 2 rows because it said ['nothing available in next fetch'].
    The code to add the columns and perform the query to get the results I am running this against:
    -- ADD column 'DateToChange'
    ALTER TABLE [HumanResources].[Employee] ADD DateToChange Date NOT NULL;
    -- Copy 'HireDate' data to 'DateToChange'
    UPDATE HumanResources.Employee SET DateToChange = HireDate;
    -- Change 'DateToChange' to NOT NULL
    ALTER TABLE [HumanResources].[Employee] ALTER COLUMN DateToChange Date NOT NULL;
    SELECT BusinessEntityID,HireDate, CONVERT( char(10),[DateToChange],101) AS [Formatted Hire Date]
    FROM HumanResources.Employee
    WHERE [DateToChange] = '04/07/2003';
    Code:
    USE AdventureWorks2012;
    GO
    -- Holds output of the CURSOR
    DECLARE @EmployeeID INT
    DECLARE @HiredDate DATETIME
    DECLARE @HiredModified DATETIME
    DECLARE @ChangeDateTo DATETIME
    --Declare cursor
    -- SCROLL CURSOR ALLOWS "for extra options" to pul multiple records: i.e. PRIOR, ABSOLUTE ##, RELATIVE ##
    DECLARE TestCursor CURSOR SCROLL FOR
    -- SELECT statement of what records going to be used by CURSOR
    -- Assign the query to the cursor.
    SELECT /*HumanResources.Employee.BusinessEntityID, HumanResources.Employee.HireDate,*/ CONVERT( char(10),[DateToChange],101) AS [Formatted Hire Date]
    FROM HumanResources.Employee
    WHERE DateToChange = '01/01/1901'
    /*ORDER BY HireDate DESC*/ FOR UPDATE OF [DateToChange];
    -- Initiate CURSOR and load records
    OPEN TestCursor
    -- Get first row from query
    FETCH NEXT FROM TestCursor
    INTO @HiredModified
    -- Logic to tell the Cursor while "@@FETCH_STATUS" 0 the cursor has successfully fetched the next record.
    WHILE (@@FETCH_STATUS = 0 AND @@CURSOR_ROWS = -1)
    BEGIN
    FETCH NEXT FROM TestCursor
    IF (@HiredModified = '04/07/2003')/*05/18/2006*/
    -- Sets @HiredModifiedDate data to use for the change
    SELECT @ChangeDateTo = '01/01/1901'
    UPDATE HumanResources.Employee
    SET [DateToChange] = @ChangeDateTo --'01/01/1901'
    FROM HumanResources.Employee
    WHERE CURRENT OF TestCursor;
    END
    -- CLOSE CURSOR
    CLOSE TestCursor;
    -- Remove any references held by cursor
    DEALLOCATE TestCursor;
    GO
    This query is run successfully but it does not produce the desired results to change the dates
    04/07/2003 to 01/01/1901.
    I would like the query to essentially be able to run the initial select statement, and then update and iterate through the returned results while replacing the necessary column in each row.
    I am also open to changes or a different design all together. 
    For this query I need:
    1. To narrow the initial set of information
    2. Check if the information returned, in particular a date, is before [i.e. this current month minus 12 months or
    12 months before current month]
    3. Next replace the dates with the needed date
    [Haven't written this out yet but it will need to be done]
    4. After all this is done I will then need to update a column on each row:
    if the 'date' is within 12 months to 12 months from the date checked
    NOTE: I am new to TSQL and have only been doing this for a few days, but I will understand or read up on what is explained if given enough information. Thank you in advance for anyone who may be able to help.

    The first thing you need to do is forget about cursors.  Those are rarely needed.  Instead you need to learn the basics of the tsql language and how to work with data in sets.  For starters, your looping logic is incorrect.  You open
    the cursur and immediately fetch the first row.  You enter the loop and the first thing in the loop does what?  Fetches another row.  That means you have "lost" the values from the first row fetched.  You also do not test the success of
    that fetch but immediately try to use the fetched value.  In addition, your cursor includes the condition "DateToChange = '01/01/1901' " - by extension you only select rows where HireDate is Jan 1 1901.  So the value fetched into @HiredModified will
    never be anything different - it will always be Jan 1 1901.  The IF logic inside your loop will always evaluate to FALSE.  
    But forget all that.  In words, tell us what you are trying to do.  It seems that you intend to add a new column to a table - one that is not null (ultimately) and is set to a particular value based on some criteria.  Since you intend the
    column to be not null, it is simpler to just add the column as not null with a default.  Because you are adding the column, the assumption is that you need to set the appropriate value for EVERY row in the table so the actual default value can be anything.
     Given the bogosity of the 1/1/1901 value, why not use this as your default and then set the column based on the Hiredate afterwards.  Simply follow the alter table statement with an update statement.  I don't really understand what your logic
    or goal is, but perhaps that will come with a better description.  In short: 
    alter table xxx add DateToChange date default '19010101'
    update xxx set DateToChange = HireDate where [some unclear condition]
    Lastly, you should consider wrapping everything you do in a transaction so that you recover from any errors.  In a production system, you should consider making a backup immediately before you do anything - strongly consider and have a good reason not
    to do so if that is your choice (and have a recovery plan just in case). 

  • Split Column group heading to next row based on row group

    Hii all 
    I am developing a matrix by grouped departments on row and schemes are in columns
    but scheme group goes to end .. its not meeting my requirement 
    as per above image my report should looks like. 
    but report looks like below ..
    Dilip Patil..

    Hi Dilip Patil,
    According to your description, you want to create a matrix which display schemes of departments. Now you can't make the matrix looks like the first image above. Right?
    In this scenario, you should have a data field in your dataset which is for the schemes to group on. Otherwise the matrix can't dynamically generate those schemes into on row. If you don't have a column in your database to group the schemes,we suggest you
    use table the render your data and put the schemes into detail rows. We have tested in our local environment. Here are steps and screeenshots for your reference:
    1. We add a column(named Scheme) in database to define scheme group for schemes.
    2. Put Dept into row group and set it group on Govt. The design looks like below:
    3. Save and preview. It looks like below:
    Reference: 
    Exporting Reports (Report Builder and SSRS)
    Matrices (Report Builder and SSRS)
    If you have any question, please feel free to ask.
    Simon Hou

  • How to suppress a row based on current date -  at query level?

    In an Bex query report i have suppress rows based on current date.
    There is no current date available in query.
    there is a date field in the query.
    If by chance the date in that field is lesser than current date, I have to suppress that row.
    How can this be achieved?

    What is the code ofr creating a variable to get values >= to current date?
    I have implemented the following code which is not working.
    data L_S_range like line of E_T_range[].
    CLEAR L_S_RANGE.
    L_S_RANGE-SIGN = 'I'.
    L_S_RANGE-OPT = 'GE'.
    L_S_RANGE-LOW = SY-DATUM.
    APPEND L_S_RANGE TO E_T_RANGE[].
    Actually i have written in class, which will be inherited in superclass.
    Edited by: akshara20 on Feb 2, 2011 1:21 PM

  • Creating a target group based on the BP email address only in CRM

    Hi there,
    I am currently trying to create a target group based on the business partner email address only.
    I have a list of over 1000 email addresses - these email addresses equate to a BP in our CRM system, however I do not have a list of the equivalent business partner numbers, all I have to work on are the email addresses.  With these 1000 BP email addresses I need to update the marketing attributes of each of these 1000 BP records in CRM.
    What I need is a method to find the 1000 BP numbers based on the email addresses and then use the marketing expert tool (tx. CRMD_MKT_TOOLS) to change the marketing attributes on all of the 1000 BPs.
    The issue I am having is how can I find the list of BP numbers just based on the BP email address, I tried creating an infoset based on table BUT000, BUT020 and ADR6 but I after creating attribute list & data source for this I am stuck on what to do next. In the attribute list the selection criteria does not allow me to import a file for the selection range.  I can only enter a value but I have 1000 email addresses and cannot possibly email them manually in the filter for the attribute list.   I also looked at imported a file into the target group but I do not have any BP numbers so this will not work.
    Does anyone know a method where I can create a target group based on the email addresses only without having to do any code?
    Any help would be most appreciated.
    Kind regard
    JoJo

    Hi JoJo ,
    The below report will return you BP GUID from emails that is stored in a single column .xls file and assign the BP to a target group.
    REPORT  zexcel.
    * G L O B A L D A T A D E C L A R A T I O N
    TYPE-POOLS : ole2.
    TYPES : BEGIN OF typ_xl_line,
    email TYPE ad_smtpadr,
    END OF typ_xl_line.
    TYPES : typ_xl_tab TYPE TABLE OF typ_xl_line.
    DATA : t_data TYPE typ_xl_tab,
           lt_bu_guid TYPE TABLE OF bu_partner_guid,
           ls_bu_guid TYPE  bu_partner_guid,
           lt_guids TYPE TABLE OF bapi1185_bp,
           ls_guids TYPE  bapi1185_bp,
           lt_return TYPE bapiret2_t.
    * S E L E C T I O N S C R E E N L A Y O U T
    PARAMETERS : p_xfile TYPE localfile,
                  p_tgguid TYPE bapi1185_key .
    * E V E N T - A T S E L E C T I O N S C R E E N
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_xfile.
       CALL FUNCTION 'WS_FILENAME_GET'
         IMPORTING
           filename         = p_xfile
         EXCEPTIONS
           inv_winsys       = 1
           no_batch         = 2
           selection_cancel = 3
           selection_error  = 4
           OTHERS           = 5.
       IF sy-subrc <> 0.
         CLEAR p_xfile.
       ENDIF.
    * E V E N T - S T A R T O F S E L E C T I O N
    START-OF-SELECTION.
    * Get data from Excel File
       PERFORM sub_import_from_excel USING p_xfile
       CHANGING t_data.
       SELECT but000~partner_guid FROM but000 INNER JOIN but020 ON
    but000~partner =
       but020~partner
         INNER JOIN adr6 ON but020~addrnumber = adr6~addrnumber INTO TABLE
    lt_bu_guid FOR ALL ENTRIES IN t_data WHERE adr6~smtp_addr =
    t_data-email.
       CLEAR: lt_guids,ls_guids.
       LOOP AT lt_bu_guid INTO ls_bu_guid.
         ls_guids-bupartnerguid = ls_bu_guid.
         APPEND ls_guids TO lt_guids.
       ENDLOOP.
       CALL FUNCTION 'BAPI_TARGETGROUP_ADD_BP'
         EXPORTING
           targetgroupguid = p_tgguid
         TABLES
           return          = lt_return
           businesspartner = lt_guids.
    *&      Form  SUB_IMPORT_FROM_EXCEL
    *       text
    *      -->U_FILE     text
    *      -->C_DATA     text
    FORM sub_import_from_excel USING u_file TYPE localfile
    CHANGING c_data TYPE typ_xl_tab.
       CONSTANTS : const_max_row TYPE sy-index VALUE '65536'.
       DATA : l_dummy TYPE typ_xl_line,
              cnt_cols TYPE i.
       DATA : h_excel TYPE ole2_object,
              h_wrkbk TYPE ole2_object,
              h_cell TYPE ole2_object.
       DATA : l_row TYPE sy-index,
              l_col TYPE sy-index,
              l_value TYPE string.
       FIELD-SYMBOLS : <fs_dummy> TYPE ANY.
    * Count the number of columns in the internal table.
       DO.
         ASSIGN COMPONENT sy-index OF STRUCTURE l_dummy TO <fs_dummy>.
         IF sy-subrc EQ 0.
           cnt_cols = sy-index.
         ELSE.
           EXIT.
         ENDIF.
       ENDDO.
    * Create Excel Application.
       CREATE OBJECT h_excel 'Excel.Application'.
       CHECK sy-subrc EQ 0.
    * Get the Workbook object.
       CALL METHOD OF h_excel 'Workbooks' = h_wrkbk.
       CHECK sy-subrc EQ 0.
    * Open the Workbook specified in the filepath.
       CALL METHOD OF h_wrkbk 'Open' EXPORTING #1 = u_file.
       CHECK sy-subrc EQ 0.
    * For all the rows - Max upto 65536.
       DO const_max_row TIMES.
         CLEAR l_dummy.
         l_row = l_row + 1.
    * For all columns in the Internal table.
         CLEAR l_col.
         DO cnt_cols TIMES.
           l_col = l_col + 1.
    * Get the corresponding Cell Object.
           CALL METHOD OF h_excel 'Cells' = h_cell
             EXPORTING #1 = l_row
             #2 = l_col.
           CHECK sy-subrc EQ 0.
    * Get the value of the Cell.
           CLEAR l_value.
           GET PROPERTY OF h_cell 'Value' = l_value.
           CHECK sy-subrc EQ 0.
    * Value Assigned ? pass to internal table.
           CHECK NOT l_value IS INITIAL.
           ASSIGN COMPONENT l_col OF STRUCTURE l_dummy TO <fs_dummy>.
           <fs_dummy> = l_value.
         ENDDO.
    * Check if we have the Work Area populated.
         IF NOT l_dummy IS INITIAL.
           APPEND l_dummy TO c_data.
         ELSE.
           EXIT.
         ENDIF.
       ENDDO.
    * Now Free all handles.
       FREE OBJECT h_cell.
       FREE OBJECT h_wrkbk.
       FREE OBJECT h_excel.
    ENDFORM. " SUB_IMPORT_FROM_EXCEL
    Just copy paste the code and run the report select any local xls file with emails and pass the target group guid.
    snap shot of excel file:
    Let me know if it was useful.

  • Summing based on matched data

    I have an odd sum issue that's been plaguing me for a year or so and I figure it's time to get it taken care of.   I have some data that I have to sum.  I have to sum them based on the data in the first column.  Easier to explain with an example.
     Note that column D is what I want the result to be... columns A, B and C are the data I'm starting with.
    A B C D117 6 0 8
    117 2 0
    118 1 0 7
    118 0 3
    118 3 0
    121 0 1 5
    121 4 0
    For the above, what I'm looking for is a total of B&C, based on the value of A...  so all the B&C values where A is 117 adds up to 8.  All the B&C values where A is 118 adds up to 7, etc.  I don't even mind if the D result is duplicated
    in every row...  So the cells in D being 8, 8, 7, 7, 7, 5, 5 would be fine.  I just need to be able to see what the totals are for all of the entries that start with "117" versus the totals of "118".  
    I know there are lots of ways to slay this beast, but my problem is that I need it done in the way I've described... no grouping, no pivot tables, no calculations elsewhere.  I have LOTS of data that will continue to grow and this all gets exported
    to other places, so the formatting has to be pretty much what I have above.  
    Can someone get me pointed in the right direction here?
    --smthng

    Re:  sum with multiple criteria in multiple columns
    With the data starting in A3 and extending to row 99...
      =SUMIF($A$3:$A$99,A3,$B$3:$B$99)+SUMIF($A$3:$A$99,A3,$C$3:$C$99)
    Jim Cone
    Portland, Oregon USA
    XL Professional excel add-in (commercial program)
    https://jumpshare.com/b/O5FC6LaBQ6U3UPXjOmX2

  • Multiple row data converted to columns

    I've seen various solutions to this, but I have one caveat: how to do it in oracle 8i and make it dynamic for a variable number of rows to columns?
    Here is an example:
    TABLE layout (unit_id and hour-ending are the PKs)
    hour_ending DATE
    unit_id NUMBER
    net_gen NUMBER
    total_unit_id NUMBERHere's a sample of data if you selected it:
    UNIT_ID  HOUR_ENDING            NET_GEN
    5297     11/1/2005 1:00:00 AM   581    
    5298     11/1/2005 1:00:00 AM   318    
    5299     11/1/2005 1:00:00 AM   91     
    5300     11/1/2005 1:00:00 AM   59     
    5301     11/1/2005 1:00:00 AM   68     
    5302     11/1/2005 1:00:00 AM   45     
    5297     11/1/2005 2:00:00 AM   625    
    5298     11/1/2005 2:00:00 AM   341    
    5299     11/1/2005 2:00:00 AM   97     
    5300     11/1/2005 2:00:00 AM   64     
    5301     11/1/2005 2:00:00 AM   74     
    5302     11/1/2005 2:00:00 AM   49      Without having to "hard code" the ids and such, what I want to do is create an SQL query that will be dynamic to create a result set as follows:
    HOUR_ENDING           UNIT_ID1  NET_GEN1  UNIT_ID2  NET_GEN2  UNIT_ID3  NET_GEN3  UNIT_ID4  NET_GEN4  UNIT_ID5  NET_GEN5  UNIT_ID6  NET_GEN6
    11/1/2005 1:00:00 AM  5297      581       5298      318       5299      91        5300      59        5301      68        5302      45
    11/1/2005 2:00:00 AM  5297      625       5298      341       5299      97        5300      64        5301      74        5302      49etc
    We have a way of getting a "list" of the units related to each other. I just need a starting point of how to format the result set based on a variable number of units that might be grouped into a row.
    Thanks!

    Thanks for the info. I guess I now have a question on how do I make this work with passing the results back to .NET? The solution in that article creates an incompatible column type for ODP.NET v9.2.0.7
    The only solution I've been able to come up with is to create a collection type in the database. The problem with that is, it is a finite number of columns. I suppose I could make it big enough to hold some huge number of columns and only use what I want to, but that makes me cringe.
    I guess I'm trying to do something that is probably not possible without a lot of effor and headaches. The reason it's this way is because we have a client that wants us to display the data that way on a form, even though that is NOT how the data is layed out in the database.
    If anyone else has any suggestions, I would appreciate it. I'm about ready to go back to the cleitn and state that what they really have here is a parent/child relationship and that it would better to display it that way, even though it means they won't see 24 hours worth of data on the screen all at once without filling up the browser window.
    Thanks!

  • Filter row data to Show Last Hour data

    Hi ALL
    I need to apply filter on Row Group in report based on last hour data from current hour .
    I'm using;
    =Datepart("h",dateadd("H",-1,now))
    On Row Group
    but it does not show any row.
    but When i used ;
    =Datepart("h","2013-12-20 01:00:00")
    It Works ..
    Kindly help me how can i filter row data to  Show Last Hour data.
    Thanks

    Thos works fine for me
    =Datepart(DateInterval.Hour,DATEAdd(DateInterval.Hour,-1,Now()))
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Problem creating a 'used sources' list based on EXIF data in InDesign CS5

    Hello everyone,
    I recently started to use InDesign CS5 to work on school projects. These projects regularly require us to have a list of sources, not only for citations and referenced work, but also for images. As I sometimes make quite long documents, keeping track of what image is where, and where I got it from, gets tedious.
    I had the idea of generating a caption based on EXIF data, which I'd move to the pasteboard, and group it with the image. The text in the caption has a seperate, numbered paragraph style. On one of the last pages, I generate a table of contents, which the numbered paragraph style selected. I chose to display it using another paragraph style, without page numbers.
    What I want to have as the end result is:
    Table of contents
    1. <Title>. <Author> (<Creation Date>). Retrieved <Date Placed> through <Description>
    The captions display correctly, as shown above in the body of the table of contents. The table of contents itself however, shows only the numbering in front of it, and not the variables.
    I already tried converting the live captions to static captions, but that doesn't work. Does anyone have an idea how to solve this?

    Hello everyone,
    I recently started to use InDesign CS5 to work on school projects. These projects regularly require us to have a list of sources, not only for citations and referenced work, but also for images. As I sometimes make quite long documents, keeping track of what image is where, and where I got it from, gets tedious.
    I had the idea of generating a caption based on EXIF data, which I'd move to the pasteboard, and group it with the image. The text in the caption has a seperate, numbered paragraph style. On one of the last pages, I generate a table of contents, which the numbered paragraph style selected. I chose to display it using another paragraph style, without page numbers.
    What I want to have as the end result is:
    Table of contents
    1. <Title>. <Author> (<Creation Date>). Retrieved <Date Placed> through <Description>
    The captions display correctly, as shown above in the body of the table of contents. The table of contents itself however, shows only the numbering in front of it, and not the variables.
    I already tried converting the live captions to static captions, but that doesn't work. Does anyone have an idea how to solve this?

  • Page break for a group and sub group based on page length

    Hi
    I have a requirement where in I need to develop a report which has the following requirement. I am attaching the sample xml and rtf files for reference:
    1) There are 3 groups in the Data Model. G1, G2 and G3. G1 contains G2 and G2 contains G3. I need to display that data in that order in the rtf template. Pretty straight forward.
    2) The tricky part, however, is that the report needs to have a page break on the following conditions:
        a) When the value of col1 changes which is in G1
        b) On col3 (in G2), but only when there is not enough space on the page to accommodate the values present in G3, ie col5 and col6 alongwith the values in G2. This means when the value of col3, which is present in G2, changes and if there is not enough space to accommodate G2 and G3 on the same page, it should break and start on a new page. The table which should come together is marked in grey color in the RTF template.
    What I have done till now to achieve this?
    I have created a parent table with two rows. In the second row I have made sure that the row doesn't break across pages. This is true for all the subsequent tables in the report. Now, in that second row, I have col1 in a nested table within a repeating group G1. Inside G1 there is a nested table for G2 and within G2 I have another table for the group G3. The row is not breaking across pages for all the tables that have been created.
    I have tried all the permutations and combinations of nested tables, keeping G1, G2 and G3 in the same table but different rows, having G1 in one table and nesting G2 and G3 in another, keeping G2 and G3 in a separate table altogether, Keeping G1, G2 and G3 all of them in the separate table. All of them are apparently not working.
    Is there anyway where we can either get hold of the current position of the cursor and the total number of rows on that page? Or any other solution that is possible? Or if I can have to make changes in the data model?
    Thanks a lot in advance
    Sid

    Hello Sid,
    I have checked your report and XML Sample and you haven't linked the fields from XML Sample to your .rtf report.
    You can use <?for-each?> syntax for your groups to print the content.
    I recommend you to review our "Creating RTF templates" manual:
    http://docs.oracle.com/cd/E28280_01/bi.1111/e22254/create_rtf_tmpl.htm#BIPRD2354
    Regards,
    Liviu

  • Month Year values based on Posting Date

    In my super huge extra large InfoCube (0CFM_C10) I got a lot of data. I take Posting Date, some KFG and CalMonth/Year. Unfortinally CalMonth/Year duplicates records, if I drop it off the columns/rows I get valid data by Posting Date.
    My question is this - is it possible to create some MonthYear Calculated KFG/field/formula or smthng. based on Posting Date? In other words I need Month/Year in rows/ columns or free characteristics...
    Edited by: Gediminas Berzanskis on Mar 18, 2008 10:18 AM

    Dear,
    When canceling a payment which was created in previous posting periods,
    we  get system message "Date deviates from permissible range",so
    the workaround is changing back the posting period to the previous one
    and try to cancel the payment.
    However,another system message pops up when we try to cancel payment
    after changing back the posting period,which is the "creation date" or
    "posting date".
    In this scenario, you should select the second option from the
    cancellation options window, which is the 'Creation date'. I would like
    to explain more below.
    Posting Date- means the posting date of the cancellation document, it's
    not the posting date of the incoming payment that you wanna perform the
    cancellation. In your case, selecting this 'posting date' option, system
    deems that you want to post this cancellation document on its own
    posting date.
    Creating Date- means the posting date/creation date of the incoming
    payment, it makes sense that the system works fine if you select this
    option. If you cancel the incoming payment and check the JE generated,
    you will find that the posting date of this cancellation document is
    actually recorded as the posting date of the incoming payment.
    Wish it helps you.If you have any problems,please kindly let me know.
    Thanks and best regards,
    Apple

Maybe you are looking for