ROLLUP for grand totals

Hi guys.
I've been trying to summarize a bunch of rows, but I'm having a little trouble doing that.
I have few nested queries which I show below:
SELECT DATA, SAP, SADIG, DIFF
  FROM (SELECT TMPSAP.DATSAP as DATA,
               TMPSAP.VALSAP as SAP,
               TMPSADIG.VALSADIG as SADIG,
               ABS(TMPSAP.VALSAP - TMPSADIG.VALSADIG) as DIFF,
               GROUPING(TMPSAP.DATSAP) AS GRUPO
          FROM (SELECT SUM(ZVLBRT) + SUM(ZDESVP) as VALSAP,
                       TO_DATE(SPTAG, 'YYYYMMDD') as DATSAP
                  FROM SAPR3.S974@PRD
                 WHERE VKORG = '1000'
                   AND (TO_NUMBER(SPART) BETWEEN 10 AND 55 OR SPART = '99')
                   AND KUNNR <> 1004
                   AND TO_DATE(SPTAG, 'YYYYMMDD') BETWEEN
                       TRUNC(TRUNC(SYSDATE, 'DD') - 1, 'MM') AND
                       TRUNC(SYSDATE, 'DD') - 1
                 GROUP BY SPTAG) TMPSAP,
               (SELECT SUM(FATDEVVLR) as VALSADIG, DATFATDEV as DATSADIG
                  FROM SADIG_FATDEV
                 WHERE BUCDG = 01
                   AND DATFATDEV BETWEEN
                       TRUNC(TRUNC(SYSDATE, 'DD') - 1, 'MM') AND
                       TRUNC(SYSDATE, 'DD') - 1
                 GROUP BY DATFATDEV) TMPSADIG
         WHERE TRUNC(TMPSAP.DATSAP, 'DD') = TRUNC(TMPSADIG.DATSADIG, 'DD')
         GROUP BY GROUPING SETS((DATSAP, VALSAP, VALSADIG),())) ALLDATA
GROUP BY ROLLUP(ALLDATA.GRUPO, ALLDATA.DATA, SAP, SADIG, DIFF)
I'm having some trouble figuring out which GROUP BY attributes I should use for the outter query, so the results I get are like these:
DATA
SAP
SADIG
DIFF
01/08/2013
1000
2000
1000
01/08/2013
1000
2000
01/08/2013
1000
01/08/2013
02/08/2013
1000
1000
0
02/08/2013
1000
1000
02/08/2013
1000
02/08/2013
03/08/2013
2000
3000
1000
03/08/2013
2000
3000
03/08/2013
2000
03/08/2013
05/08/2013
5000
5000
0
05/08/2013
5000
5000
05/08/2013
5000
05/08/2013
06/08/2013
1000
2000
1000
06/08/2013
1000
2000
06/08/2013
1000
06/08/2013
If you look at my second select layer (the one that returns ALLDATA), my results are like these:
DATA
SAP
SADIG
DIFF
GRUPO
01/08/2013
1000
2000
1000
0
02/08/2013
1000
1000
0
0
03/08/2013
2000
3000
1000
0
05/08/2013
5000
5000
0
0
06/08/2013
1000
2000
1000
0
1
And what I want is this:
DATA
SAP
SADIG
DIFF
01/08/2013
1000
2000
1000
02/08/2013
1000
1000
0
03/08/2013
2000
3000
1000
05/08/2013
5000
5000
0
06/08/2013
1000
2000
1000
10000
13000
3000
I've tried several combinations in ROLLUP, but without success. What am I missing?
Thank you very much!
Best regards,
Vinicius

Hi, Frank! Thank you for your quick reply.
Just for reference, all my queries are running under Oracle 9.2.0.1.0, unless otherwise specified.
First of all, I'm sorry if I wasn't clear. I tried to provide as much information as possible, so I think I might have made things a little fuzzy.
Also, it's my very first post in this forum, so I'm not really used to oracle community standards - and I apologize for that.
Moving on, unfortunately, I'm a little way too much confused, so I don't know exactly a good way to simplify my problem, so going a little against of your advice, I'll dig a little deeper and unravel the matter in unitary steps. Also, unfortunately I can't provide CREATE TABLE or INSERT statements, since I really don't know what the whole structure behind the databases is. What I can is to provide a few CREATE TABLE and INSERT statements regarding step 2 and forward, so you could at least reproduce the situation. Here's the SQL:
CREATE TABLE TMPSAP (DATSAP DATE NOT NULL, VALSAP NUMBER (8,2) NOT NULL);
CREATE TABLE TMPSADIG (DATSADIG DATE NOT NULL, VALSADIG NUMBER (8,2) NOT NULL);
INSERT INTO TMPSAP VALUES(TO_DATE('01/08/2013','DD/MM/YYYY'), 300);
INSERT INTO TMPSAP VALUES(TO_DATE('02/08/2013','DD/MM/YYYY'), 1000);
INSERT INTO TMPSAP VALUES(TO_DATE('03/08/2013','DD/MM/YYYY'), -500);
INSERT INTO TMPSAP VALUES(TO_DATE('05/08/2013','DD/MM/YYYY'), 5000);
INSERT INTO TMPSAP VALUES(TO_DATE('06/08/2013','DD/MM/YYYY'), 1200);
INSERT INTO TMPSAP VALUES(TO_DATE('07/08/2013','DD/MM/YYYY'), 1800);
INSERT INTO TMPSADIG VALUES(TO_DATE('01/08/2013','DD/MM/YYYY'), 100);
INSERT INTO TMPSADIG VALUES(TO_DATE('02/08/2013','DD/MM/YYYY'), 1000);
INSERT INTO TMPSADIG VALUES(TO_DATE('03/08/2013','DD/MM/YYYY'), -500);
INSERT INTO TMPSADIG VALUES(TO_DATE('05/08/2013','DD/MM/YYYY'), 5000);
INSERT INTO TMPSADIG VALUES(TO_DATE('06/08/2013','DD/MM/YYYY'), 1200);
INSERT INTO TMPSADIG VALUES(TO_DATE('07/08/2013','DD/MM/YYYY'), 1800);
COMMIT;
Other than that, let me try it again:
I have two tables in two different systems which should have the same sum of values for one of their fields, given a date.
Step 1:
To check that, I have one query in one of those tables (which I'll call TMPSAP for now), which is running under Oracle 9.2.0.7.0 and accessed via DBLINK, that sums all the values and group them per date:
SELECT TO_DATE(SPTAG, 'YYYYMMDD') as DATSAP, SUM(ZVLBRT) + SUM(ZDESVP) as VALSAP                
                  FROM SAPR3.S974@PRD
                 WHERE VKORG = '1000'
                   AND (TO_NUMBER(SPART) BETWEEN 10 AND 55 OR SPART = '99')
                   AND KUNNR <> 1004
                   AND TO_DATE(SPTAG, 'YYYYMMDD') BETWEEN
                       TRUNC(TRUNC(SYSDATE, 'DD') - 1, 'MM') AND
                       TRUNC(SYSDATE, 'DD') - 1
                 GROUP BY SPTAG
                 ORDER BY DATSAP
Which returns:
DATSAP
VALSAP
01/08/2013
300
02/08/2013
1000
03/08/2013
-500
05/08/2013
5000
06/08/2013
1200
07/08/2013
1800
Step 2:
Likewise, I have another query running in the other system's tables (which I'll call TMPSADIG for now), that sums all the values and group them per date:
SELECT DATFATDEV as DATSADIG, SUM(FATDEVVLR) as VALSADIG
                  FROM SADIG_FATDEV
                 WHERE BUCDG = 01
                   AND DATFATDEV BETWEEN
                       TRUNC(TRUNC(SYSDATE, 'DD') - 1, 'MM') AND
                       TRUNC(SYSDATE, 'DD') - 1
                 GROUP BY DATFATDEV
                 ORDER BY DATSADIG
Which returns:
DATSADIG
VALSADIG
01/08/2013
100
02/08/2013
1000
03/08/2013
-500
05/08/2013
5000
06/08/2013
1200
07/08/2013
1800
Step 3:
I run a query (which I'll call ALLDATA for now) in those two tables, joining them by date and calculating the difference between the values:
SELECT TMPSAP.DATSAP as DATA,
               TMPSAP.VALSAP as SAP,
               TMPSADIG.VALSADIG as SADIG,
               ABS(TMPSAP.VALSAP - TMPSADIG.VALSADIG) as DIFF,
               GROUPING(TMPSAP.DATSAP) AS GRUPO
          FROM TMPSAP, TMPSADIG
         WHERE TRUNC(TMPSAP.DATSAP, 'DD') = TRUNC(TMPSADIG.DATSADIG, 'DD')
         GROUP BY GROUPING SETS((DATSAP, VALSAP, VALSADIG),())
         ORDER BY TMPSAP.DATSAP
Which returns:
DATA
SAP
SADIG
DIFF
GRUPO
01/08/2013
300
100
200
0
02/08/2013
1000
1000
0
0
03/08/2013
-500
-500
0
0
05/08/2013
5000
5000
0
0
06/08/2013
1200
1200
0
0
07/08/2013
1800
1800
0
0
Step 4:
And now I need to run a mysterious query in ALLDATA (results above), that will return me these exact results:
DATA
SAP
SADIG
DIFF
01/08/2013
300
100
200
02/08/2013
1000
1000
0
03/08/2013
-500
-500
0
05/08/2013
5000
5000
0
06/08/2013
1200
1200
0
07/08/2013
1800
1800
0
Total:
8800
8600
200
Which means, I need to add a row in the end of the query, containing the sum of all previous rows (the one in red). I've been messing around with ROLLUP and other grouping functions, but I couldn't really manage to achieve anything even close to that.
Of course I could run the query again and sum everything and union all, or even run this from a stored procedure and summarize with some coding, but the point of my whole thread is: Is there any way to do that using nothing more than a query?
I hope I clarified what I'm looking for and I apologize if it is still unclear or too messy, but I really can't find another way to present the information.
And I also hope someone can help me find a way to do that.
Thank you very much!
Kind regards,
Vinicius

Similar Messages

  • Currency symbol only for grand total.

    Hi,
    My requirement is i want currency symbol $ only for grand total, all the rows in that column do not have the symbol.
    I need some your help.
    Thank you.

    Although I couldn't understand why you dont want currency format in rows, here is my suggestion.
    Create your report as
    1 dim1.column1 dim2.column2 Measure.Revenue ......... You will get values as below
    1 Value1 Dim2Val1 100
    1 Value2 Dim2Val2 200
    1 Value2 Dim2Val3 300
    UNION
    2 'Grand Total' ' ' Measure.Revenue
    Final result will be as below
    1 Value1 Dim2Val1 100
    1 Value2 Dim2Val2 200
    1 Value2 Dim2Val3 300
    2 Grand Total 600
    Now apply conditional formatting for dim1.column1 in criteria and make the values Bold
    Apply conditional formatting for Measure.Revenue and select Currency in number format.
    Let me know if it was helpful or you were looking for something else.
    Thanks

  • ALV GRID - Text for Grand Total

    Hi guys,
    In ALV Grid, i need to display the Text 'GRAND TOTAL' at the left side of the row(Yellow line).
    I have tried searching in the forum but didn't get the answer.
    Please advice.
    Thanks
    Chintu

    Hi
    <br><br>
    IF you copy and past this might not work but this is the sample code<br><br>
    <pre>
    REPORT  Y_DOWN_TIME_ENTRYSRA.
    TABLES : YDOWNTIME1.
    TYPE-POOLS : SLIS.
    *INTERNAL TABLE DECLARTION
    data : l_layout type slis_layout_alv,
           x_events type slis_alv_event,
           it_events type slis_t_event.
    DATA :ITAB LIKE YDOWNTIME1 OCCURS 0 WITH HEADER LINE .
    data :  GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
          wa_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
    **********************SELECTION PARAMETERS ************************
    PARAMETERS: CB1 RADIOBUTTON GROUP G1 ,
                CB2 RADIOBUTTON GROUP G1 ,
                cb3 RADIOBUTTON GROUP G1 ,
                CB4 RADIOBUTTON GROUP G1 ,
                CB5 RADIOBUTTON GROUP G1 ,
                CB6 RADIOBUTTON GROUP G1 ,
                CB7 RADIOBUTTON GROUP G1 ,
                CB8 RADIOBUTTON GROUP G1 ,
                CB9 RADIOBUTTON GROUP G1 .
               CB10 RADIOBUTTON GROUP G1,
               CB11 RADIOBUTTON GROUP G1.
    DATA : A TYPE C.
    SELECTION-SCREEN BEGIN OF BLOCK BK1 WITH FRAME TITLE TEXT-001.
      SELECT-OPTIONS :S_EQUNR         FOR  YDOWNTIME1-EQUNR ,
                      S_ERDop        FOR  YDOWNTIME1-ERDAT,
                      S_MFSTT         FOR  YDOWNTIME1-MFSTART.
      PARAMETERS :    P_SHIFT         TYPE YDOWNTIME1-SHIFT,
                      P_CHARG         TYPE YDOWNTIME1-CHARG,
                      p_COGRU         TYPE YDOWNTIME1-QMGRP,
                      P_CODE          TYPE YDOWNTIME1-COde,
                     p_name          type ydowntime1-OPNAME,
                      p_sup           TYPE YDOWNTIME1-SUPERVISOR,
                      P_MANG           TYPE YDOWNTIME1-MANG.
    SELECTION-SCREEN END OF BLOCK BK1 .
    AT SELECTION-SCREEN.
      IF CB1 EQ 'X'.
        select  * from YDOWNTIME1
             INTO  CORRESPONDING FIELDS OF TABLE   ITAB
                   where erdat in S_ERDop  .
      ELSEIF CB2 EQ 'X' .
         select  * from YDOWNTIME1
           INTO  CORRESPONDING FIELDS OF TABLE   ITAB
           where erdat in S_ERDop and  charg eq p_charg .
      ELSEIF CB3 EQ 'X' .
         select  * from YDOWNTIME1
           INTO  CORRESPONDING FIELDS OF TABLE   ITAB
           where erdat in S_ERDop and charg  eq p_charg and shift eq P_SHIFT .
      ELSEIF  CB4 EQ 'X' .
        select  * from YDOWNTIME1
           INTO  CORRESPONDING FIELDS OF TABLE   ITAB
           where  code eq p_code and  erdat in S_ERDop.
      ELSEIF  CB5 EQ 'X' .
        select  * from YDOWNTIME1
           INTO  CORRESPONDING FIELDS OF TABLE   ITAB
           where  erdat in S_ERDop and EQUNR in S_EQUNR and QMGRP eq p_COGRU.
      ELSEIF  CB6 EQ 'X' .
        select  * from YDOWNTIME1
           INTO  CORRESPONDING FIELDS OF TABLE   ITAB
           where  OPNAME eq p_name and  erdat in S_ERDop.
      ELSEIF   CB7 EQ 'X' .
        select  * from YDOWNTIME1
           INTO  CORRESPONDING FIELDS OF TABLE   ITAB
           where SUPERVISOR eq p_sup and  erdat in S_ERDop.
      ELSEIF   CB8 EQ 'X' .
        select  * from YDOWNTIME1
           INTO  CORRESPONDING FIELDS OF TABLE   ITAB
           where MANG eq p_MANG and  erdat in S_ERDop.
      ELSEIF   CB9 EQ 'X'.
        select  * from YDOWNTIME1
           INTO  CORRESPONDING FIELDS OF TABLE   ITAB
           where erdat in S_ERDop and EQUNR in S_EQUNR.
      endif.
    loop at itab.
    if itab-schno > 1.
      A = '  '.
      move A to itab-DCOR .
      move A to itab-DCCR .
      move A to itab-DCNR .
      modify itab.
    endif.
    endloop.
    perform create_fieldcat.
    data: sort type slis_sortinfo_alv,
          it_sort type  SLIS_T_SORTINFO_ALV.
    sort-fieldname = 'EQUNR'.
    sort-up = 'X'.
    sort-subtot = 'X'.
    APPEND sort to it_sort.
    sort-fieldname = 'SHIFT'.
    sort-up = 'X'.
    *sort-subtot = 'X'.
    APPEND sort to it_sort.
    l_layout-TOTALS_TEXT = 'TOTAL'.
    l_layout-SUBTOTALS_TEXT = 'SUBTOTAL'.
       CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
        i_callback_program       = sy-repid
        is_layout                = l_layout
        it_fieldcat              = gt_fieldcat
        it_events                = it_events
        it_sort                  = it_sort
      TABLES
        T_OUTTAB                       = ITAB
    EXCEPTIONS
       PROGRAM_ERROR                  = 1
       OTHERS                         = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    *&      Form  CREATE_FIELDCAT
          text
    -->  p1        text
    <--  p2        text
    FORM CREATE_FIELDCAT .
      DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '1'.
      LS_FIELDCAT-FIELDNAME   = 'ERDAT'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '12'.
    ls_fieldcat-do_sum       = 'X'.
      LS_FIELDCAT-SELTEXT_L =  'Date'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
      clear LS_FIELDCAT .
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '2'.
      LS_FIELDCAT-FIELDNAME   = 'UZEIT'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '8'.
      LS_FIELDCAT-SELTEXT_L =  'Time'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
       CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '2'.
      LS_FIELDCAT-FIELDNAME   = 'EQUNR'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '8'.
      LS_FIELDCAT-SELTEXT_L =  'Equipment'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '2'.
      LS_FIELDCAT-FIELDNAME   = 'CODE'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '12'.
      LS_FIELDCAT-SELTEXT_L =  'CODE'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '3'.
      LS_FIELDCAT-FIELDNAME   = 'QMGRP'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '20'.
      LS_FIELDCAT-SELTEXT_L =  'Code Group'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
    CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '3'.
      LS_FIELDCAT-FIELDNAME   = 'KURZTEXT'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '40'.
      LS_FIELDCAT-SELTEXT_L =  'Code Text'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
       CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '7'.
      LS_FIELDCAT-FIELDNAME   = 'DCOR'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '14'.
      LS_FIELDCAT-SELTEXT_L =  'Opening Dips'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
        CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '8'.
      LS_FIELDCAT-FIELDNAME   = 'DCCR'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '14'.
      LS_FIELDCAT-SELTEXT_L =  'Closing Dips'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '9'.
      LS_FIELDCAT-FIELDNAME   = 'DCNR'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '10'.
      ls_fieldcat-do_sum       = 'X'.
      LS_FIELDCAT-SELTEXT_L =  'Net Dips'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
    CLEAR LS_FIELDCAT.
    LS_FIELDCAT-ROW_POS     = '1'.
    LS_FIELDCAT-COL_POS     = '9'.
    LS_FIELDCAT-FIELDNAME   = 'PRO'.
    LS_FIELDCAT-KEY         = ''.
    LS_FIELDCAT-OUTPUTLEN   = '10'.
    ls_fieldcat-do_sum       = 'X'.
    LS_FIELDCAT-SELTEXT_L =  'PROD IN LAC'.
    APPEND LS_FIELDCAT TO GT_FIELDCAT.
       clear LS_FIELDCAT .
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '4'.
      LS_FIELDCAT-FIELDNAME   = 'CHARG'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '12'.
      ls_fieldcat-do_sum       = 'X'.
      LS_FIELDCAT-SELTEXT_L =  'Batch Number'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '6'.
      LS_FIELDCAT-FIELDNAME   = 'OPNAME'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '20'.
      LS_FIELDCAT-SELTEXT_L =  'Operators Name'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
    CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '6'.
      LS_FIELDCAT-FIELDNAME   = 'SUPERVISOR'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '20'.
      LS_FIELDCAT-SELTEXT_L =  'Supervisor Name'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
         CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '6'.
      LS_FIELDCAT-FIELDNAME   = 'MANG'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '20'.
      LS_FIELDCAT-SELTEXT_L =  'Manager'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '6'.
      LS_FIELDCAT-FIELDNAME   = 'SHIFT'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '20'.
      LS_FIELDCAT-SELTEXT_L =  'Shift'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
    CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '9'.
      LS_FIELDCAT-FIELDNAME   = 'MFSTART'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '10'.
      LS_FIELDCAT-SELTEXT_L =  'Start Time'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
       CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '9'.
      LS_FIELDCAT-FIELDNAME   = 'MFEND'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '10'.
      LS_FIELDCAT-SELTEXT_L =  'End Time'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
       CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '9'.
      LS_FIELDCAT-FIELDNAME   = 'DURATION'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '10'.
      ls_fieldcat-do_sum       = 'X'.
      LS_FIELDCAT-SELTEXT_L =  'DURATION'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
        CLEAR LS_FIELDCAT.
      LS_FIELDCAT-ROW_POS     = '1'.
      LS_FIELDCAT-COL_POS     = '9'.
      LS_FIELDCAT-FIELDNAME   = 'ZUNIT'.
      LS_FIELDCAT-KEY         = ''.
      LS_FIELDCAT-OUTPUTLEN   = '10'.
      LS_FIELDCAT-SELTEXT_L =  'UNIT'.
      APPEND LS_FIELDCAT TO GT_FIELDCAT.
        clear LS_FIELDCAT .
    ENDFORM.                    " CREATE_FIELDCAT
    </pre>
    Edited by: Matt on Sep 3, 2009 12:06 PM

  • *urgent* Alternate colors for Grand total values

    Hi all,
    I have 1 dimension column and 4 fact columns. Here I perform Grand total for the request .
    The requirement is :---
    I need alternate colors as background for the Grand total values.
    Am trying to modify the XML in Advanced tab .
    I tried to do it by using combine request .
    Please help on this . Urgent .
    Thanks a lot in advance for every reply .

    Please give some suggestions.

  • Alternating colors for grand total  values

    hii
    i hve a requirement that grandtotal values should be displayed in alternate colors..actualy grand total values be in blue..bt i need the alternate colors for the values of grand total..pls help me regarding this..

    Please give some suggestions.

  • Valid Scrypt for Grand Total

    I have created an expanding table, using the following link:
    http://forms.stefcameron.com/2009/02/25/expandable-table-with-totals/
    (instructions shown below)
    However, I have been unsuccessful with the Grand Total value. As shown in the picture below, the rest of the totals show but the Grand Total remains blank. I must include the Installation fee (marked by the check box)
    This is the last step needed to complete my form, I would really appreciate all the help i can receive.
    Thank you!

    Row1[x] (where x is an integer) is the name and subscript for your rows. In the example, Stef (if that's his real name) used Item as the name for his rows. In your form, you are using Row1. So, each row is named Row1[0], Row1[1], Row1[2], etc... Inside of each Row1, you have a text field called "Total." Since you're using formCalc, you are summing the total of those rows using Row1[*].Total. So, if you haven't changed anything else, you should (at the very least) be able to sum the rows in the grand total box using
    $.rawValue = Sum(Row1[*].Total)
    Now, the checkbox is a different story. The checkbox has an "on" value and an "off" value. We can use that in formCalc to more easily add it to the value that we're going to get for the grand total. If you set the "on" value to 300 (I included an illustration of that in my first picture), then you can use the name of the checkbox to get your total. If the checkbox is checked or "on", then the on value (300 in my example) gets added to the total, and if it's unchecked or "off", then the off value (0 in my example) gets added. The checkbox also has to have it's name correct. In my example it's called CheckBox1, in your code you have Installation. So, whatever you named the checkbox needs to go at the end of the formula we're using like so.
    $.rawValue = Sum(Row1[*].Total) + Installation
    If you named your checkbox something else, then you'll need to change the word "Installation" to whatever the checkbox is named. (The name is in the hierarchy tree.)

  • How to summarize the formula field for grand total

    Hi All
    Iam desinging a report in which iam facing a problem to summarize the formula field . This formula field contains sum calculation like
    formula name is @sales
    Sum ({@DTM200}, {@SaleMan})+Sum ({@DTM500}, {@SaleMan})+
    Sum ({@TM500}, {@SaleMan})+Sum ({@TM1000}, {@SaleMan})+
    Sum ({@HTM500}, {@SaleMan})+Sum ({@HTM1000}, {@SaleMan})+
    Sum ({@WM500}, {@SaleMan})+Sum ({@WM1000}, {@SaleMan})+
    Sum ({@CURD}, {@SaleMan})+Sum ({@Buttermilk}, {@SaleMan})+
    Sum ({@BULKWM}, {@SaleMan})+Sum ({@BULKTM}, {@SaleMan})
    the fields are summary fields and iam calculating all these fields to get the final result . Upto this it is working fine but finally i want to calculate the grand total of this formula '@sales' how should do this
    Thanks in advance

    Hi,
    If your formula name is @Sales you click the @Sales formula then Click Insert from Menu bar and click Summary.
    Then click Grand Total.
    Regards,
    Clint

  • Specific aggregation for Grand total

    Hi all,
    Is it possible to specify a function instead of the provided list of aggregation rules in answers or in the rpd.
    I'd like to calculate SUM(Xi)/SUM(count(Xi)) and display it as a grand total
    __________Column X
    ___________10
    ___________20
    ___________30
    Grand total 20 (60/3=20)
    Regards

    what is the grand total formula you are expecting?
    if you post it here we can sort it out.
    You can find the 'Combine with similar Request' option in the criteria.
    click on that and select your subject area and select the exact columns you used in your report. Now in this report change the formula to the one you want.
    in your first column delete the formula and simply type 'Grand Total' and in the second column type
    sum(column_name)/count(column_name)
    you can ref to this link. just take how they are using 'UNION' request in the example. Though the link is not totally relevant to you it will help you.
    http://oraclebizint.wordpress.com/2008/01/25/oracle-bi-ee-101332-dynamic-column-headers-using-presentation-variables-sets-and-conditional-formatting/

  • Rollup for Sub-total and add opening balance

    Hi,
    I have a table which contains the data for customer transaction for certen period.
    Data will be queried for certain transaction period.
    CUST_TRAN_DETS
    A/c No - trans_nr - trans_typ - opening_bal - tran_dat_fr - trans_dat_to -- trans_amt
    123 - 10001 - Op.Bal - 500000 - 01.12.06 - 30.12.06
    123 - 10002 - invoice - 000000 - 01.01.07 - 31.01.07 - 20000.00
    124 - 10003 - invoice - 000000 - 01.02.07 - 28.02.07 - 30000.00
    124 - 10004 - invoice - 000000 - 01.03.07 - 30.03.07 - 120000.00
    124 - 10005 - invoice - 000000 - 01.04.07 - 31.04.07 - 85000.00
    125 - 10006 - invoice - 000000 - 01.04.07 - 31.04.07 - 30000.00
    125 - 10007 - invoice - 000000 - 01.04.07 - 31.04.07 - 14000.00
    125 - 10008 - invoice - 000000 - 01.04.07 - 31.04.07 - 170000.00
    Now my query should return following output
    A/c No. -tran_dat_fr- trans_dat_to - curr_bal- Total_bal
    123 -- 01.01.07 -- 31.01.07 -- 20000.00
    124 -- 01.02.07 -- 31.04.07 -- 235000.00
    125 -- 01.04.07 -- 31.04.07 -- 184000.00
    939000.00
    Each subtotal on A/c number should sum the trans amt for each a/c no for that period. And the total_bal should display the sum of transactions for all account numbers for that period and Opening balance. In the above exmpl, Total bal would be 20000+235000+1840000+500000.
    Pls help ASAP.
    Regards
    Ram

    SQL> create table cust_tran_dets (ac_no,trans_nr,trans_type,opening_bal,tran_dat_fr,tran_dat_to,trans_amt)
      2  as
      3  select 123, 10001, 'Op.Bal', 500000, date '2006-12-01', date '2006-12-31', null from dual union all
      4  select 123, 10002, 'invoice', 0, date '2007-01-01', date '2007-01-31', 20000 from dual union all
      5  select 124, 10003, 'invoice', 0, date '2007-02-01', date '2007-02-28', 30000 from dual union all
      6  select 124, 10004, 'invoice', 0, date '2007-03-01', date '2007-03-31', 120000 from dual union all
      7  select 124, 10005, 'invoice', 0, date '2007-04-01', date '2007-04-30', 85000 from dual union all
      8  select 125, 10006, 'invoice', 0, date '2007-04-01', date '2007-04-30', 30000 from dual union all
      9  select 125, 10007, 'invoice', 0, date '2007-04-01', date '2007-04-30', 14000 from dual union all
    10  select 125, 10008, 'invoice', 0, date '2007-04-01', date '2007-04-30', 170000 from dual
    11  /
    Tabel is aangemaakt.
    SQL> select ac_no
      2       , case when grouping(ac_no) = 0 then min(decode(trans_type,'invoice',tran_dat_fr)) end tran_dat_fr
      3       , case when grouping(ac_no) = 0 then max(decode(trans_type,'invoice',tran_dat_to)) end tran_dat_to
      4       , case when grouping(ac_no) = 0 then sum(decode(trans_type,'invoice',trans_amt)) end curr_bal
      5       , case when grouping(ac_no) = 1 then sum(opening_bal + nvl(trans_amt,0)) end total_bal
      6    from cust_tran_dets
      7   group by rollup(ac_no)
      8  /
         AC_NO TRAN_DAT_FR         TRAN_DAT_TO           CURR_BAL  TOTAL_BAL
           123 01-01-2007 00:00:00 31-01-2007 00:00:00      20000
           124 01-02-2007 00:00:00 30-04-2007 00:00:00     235000
           125 01-04-2007 00:00:00 30-04-2007 00:00:00     214000
                                                                      969000
    4 rijen zijn geselecteerd.Regards,
    Rob.

  • Sub total wise Grand total in ALV report

    Dear All,
    I am displaying a list of material through material group wise so for each material i want to display sub-total for stock and grand total of stock(material group wise).Here it is adding up all the stock displayed for different AUOM(alternative unit of measure ) which is for same material so i want to pick only the sub-total and sum up in my Grand total.
    How to pick only the Sub-total Results and Add in ALV List for Grand total.
    Thanks & Regards,
    Arun.
    Edited by: Arun Kumaran on Sep 24, 2008 7:46 AM

    Hi arun,
    check these links
    total and subtotal in alv
    ALV SUBTOTAL
    Regards,
    Anirban

  • Obiee 11G - Show grand total in chart

    I have three measures in my table.
    Measure 1 - Rolling balance from the current and previous month.
    Measure 2 - PeriodRolling revenue for the last three months including current month
    Measure 3 - Calculation using measure 1 and measure 2 and the number of  days.
    I have created all three measures in the RPD.
    The table is by state. So it could be Texas, New York, Illinois and so on.
    Month
    State
    Measure 1
    Measure 2
    Measure 3
    1
    Texas
    17565
    9898989
    45
    1
    New York
    97848
    8748575
    43
    2
    Texas
    85768
    8734874
    33
    2
    New york
    94855
    3234442
    23
    The chart shows the trend of Measure 3 by time for each state. I need a line on the chart to show the total by month. Do I have to create a sum() formula in the RPD? Appreciate any ideas that you can throw at me.

    I created a new group in the selection step and included all the states in it. That seemed to work. The Graph shows a line for grand total. Thank you for your help.
    The requirement is to create a line chart. I don't think a bar would work as well here.

  • Wrong SSAS Grand Total Value Monthly Value base on Weekly Value

    Dear All, 
    I Have calculated measures in my cube base on Weekly and Base on Monthly and different
    Template Base .
    For grand Total Weekly is fine but for Monthly is bad one.
    Say calculated Measure Name "Weekly" with Syntax
    CREATE MEMBER CURRENTCUBE.[Measures].[Weekly]
     AS IIF(isempty([Measures].[Actual Quantity MTD]) or [Measures].[Actual Quantity MTD]=0 or isempty([Measures].[Original Plan Quantity  MTD])   , null ,
    IIF([Measures].[Original Plan Quantity MTD] =0 or isempty([Measures].[Original Plan Quantity MTD]),null,   
    IIF( 
     ([Measures].[Actual Quantity MTD]-[Measures].[Original Plan Quantity MTD]) > 0 , 1 ,[Measures].[Actual Quantity MTD]/ [Measures].[Original Plan Quantity MTD] ))) 
    The Result is good
    here the picture
    http://hpics.li/9fd22f2
    https://drive.google.com/open?id=0ByY5H-XcydgiWGp0RzdWYWp0M2c&authuser=0
    and for Monthly Calculation  it was AVG of Weekly base on Time, Plant, and PSL Dimension 
    My calculated Monthly Measure Name "Monthly" with Syntax
    CREATE MEMBER CURRENTCUBE.[Measures].[Monthly]
     AS AVG ( 
    DESCENDANTS([PSL].[PSL Description])*
    DESCENDANTS([Plant].[Plant])*
    DESCENDANTS([Finish Date].[Calendar],[Finish Date].[Calendar].[Month Year]) 
    , AVG(([Finish Date].[Calendar].CURRENTMEMBER.CHILDREN), [Measures].[Weekly]))
    The Result is Bad on Grand total 
    here the Picture link 
    http://hpics.li/5233b50
    https://drive.google.com/open?id=0ByY5H-XcydgicEhtT1FpekRsbW8&authuser=0
    Please help me why for the Result doesn't same. What do i Miss
    Thank You 
    Yan

    Hi Yan,
    According to your description, you create a calculated measure in your cube, the problem is that grand Total for Monthly is incorrect, right?
    In your scenario, the issue can be caused by that you used "*" and "/" in your calculated measure. In SSAS, one of the most common issues faced in mdx is grand total or sub total not coming properly when some arithmetic operations like
    measure1 [* or + or - or /] measure2 is used, please refer to the link below to see the details.
    http://vnu10.blogspot.jp/2011/01/mdx-grand-total-sub-total.html
    Regards,

  • Using variable in Grand Total Label

    Hi All,
    I am using OBIEE 11.1.1.5 on Windows Vista.
    Can we use variable values in Grand Total label in pivot and table views?
    For eg. If user chose 2013 in dashboard prompt and we saved that in a presentation variable and want to use in the Grand Total label
    so that instead of text "Grand Total" we can show "Fiscal Year 2013 Total".
    Regards,
    Vikas
    Edited by: Vikas Barsaiyan on Feb 1, 2013 2:34 AM
    Edited by: Vikas Barsaiyan on Feb 1, 2013 2:34 AM

    I dont think but you may go for custom captions
    You can refere @ for 'Grand Total'
    In caption Year@ results YearGrand Total
    Other workaround : Use Narrative views to refer the variables, you might need to call variable in any of column expression and call it @n
    where n is for column position from left to right
    If helps mark
    Edited by: Srini VEERAVALLI on Jan 31, 2013 3:17 PM

  • Problem with Grand total in Crystal report xi

    Post Author: eshwar_polawar
    CA Forum: Crystal Reports
    Dear all,
    I am facing the problem with Grand total field in Report footer.Please advise me how should we resolve it.
    My report design as follows
    Report Title
    Page Header section:
    charged date    fee_ description charge_ amount currency_code
    Group  Header #1(Group by bank_ref)
    Group Header #2(Group by Currency code)
    Details
    charged date    fee_ description charge_ amount currency_code
    Group Footer#2 
    (Sub Total )
    Running Total field(Fields to Summarize on Charge_amount, Evaluate on "Group2# change of currency code) ,Sum of Charge_amount,Currency_ code
    Report footer:
    Sum of (charge_amount) currecy code
    Example of data:
    charged date   fee desc   chrage amount  currencycode
    0000000060129
    CAD
    10-Oct-2007    Transfer     200   Cad
    11-Oct-2007  comm          150 cad
    Sub total                        350 Cad
    0000000060129
    CAD
    10-Oct-2007    Transfer     100   USD
    11-Oct-2007  comm          150  USD
    Sub total                        250 USD
    Grand total     should   350 CAD  but it is showing  all total amoun 1000 CAD ,Group by Curreny code in the table
                                        250 USD but it is showing all  total amount 1200 USD
    Please provide the solutions like:
    1).About Running total in Report footer section
    2).Formula on While printing records for grand total
    3).How will send links with subreports
    Thanks and Regards
    Eshwar

    Post Author: eshwar_polawar
    CA Forum: Crystal Reports
    eshwar_polawar:
    Dear all,
    I am facing the problem with Grand total field in Report footer.Please advise me how should we resolve it.
    My report design as follows
    Report Title
    Page Header section:
    charged date    fee_ description charge_ amount currency_code
    Group  Header #1(Group by bank_ref)
    Group Header #2(Group by Currency code)
    Details
    charged date    fee_ description charge_ amount currency_code
    Group Footer#2 
    (Sub Total )
    Running Total field(Fields to Summarize on Charge_amount, Evaluate on "Group2# change of currency code) ,Sum of Charge_amount,Currency_ code
    Report footer:
    Sum of (charge_amount) currecy code
    Example of data:
    charged date   fee desc   chrage amount  currencycode
    0000000060129
    CAD
    10-Oct-2007    Transfer     200   Cad
    11-Oct-2007  comm          150 cad
    Sub total                        350 Cad
    0000000060129
    CAD
    10-Oct-2007    Transfer     100   USD
    11-Oct-2007  comm          150  USD
    Sub total                        250 USD
    Grand total     should   350 CAD  but it is showing  all total amoun 1000 CAD ,Group by Curreny code in the table
                                        250 USD but it is showing all  total amount 1200 USD
    Please provide the solutions like:
    1).About Running total in Report footer section
    2).Formula on While printing records for grand total
    3).How will send links with subreports
    Thanks and Regards
    Eshwar

  • Customizing grand total columns in pivot view

    Hi,
    I need to customize grand total column name in pivot view
    ex: If i have two measure order quantity and order amount when i am selecting aggregation after in column properties it is getting grand total i need to display as grand total for OQ and grand total for OA
    Please give suggestions
    Thanks,
    Kartheek.
    Edited by: 998231 on May 26, 2013 11:31 PM

    Hi Kartheek,
    In Pivot View, the default Grand Total can not be renamed to have measure specific grand total labe (The one which we specify in the pivot view either by row or column).
    But you can try having one seperate measure (in criteria) which will calculate the grand total of each measure by dimensions, which are available on the report.
    In sort you can achieve this using table and narrative view together (Not by pivot view).
    Expresion to be used for grand total in report criteria is Sum( Measure By Dim1, dim2... DimN)
    where Dim1 and dim2 are the dimesional column available on the report and measure is you OQ/OA.
    Create a table view as a default view (do not add any report level agg) and then add narrative view to display the Grand total OQ and Grand Total OA. You can add your custom lables with HTML tag, disply the 1st row only as the values will be repeated for grand total.
    If you find any other solution do let me know. As of now I can think of this as a best solution.
    Regards,
    Kashi

Maybe you are looking for

  • Discoverer Report Optimization

    Hi Im a newbiew at using this forum, my question is what is the first thing to look for when you're doing optimization (reports that are running too long)? I've tried isolating where it is slowing down and so far I've discovered that it's coming from

  • How can I remove a previously used Apple ID from my iPhone? My phone is saying to update apps but asks for the other Apple ID password

    I signed in on my phone with my wife's Apple ID and downloaded an app then signed out of hers. I signed back in with mine and now, my phone remembers I did that obviously because it says I have apps that need to be updated and when I chose to update

  • EMail completed form in Acrobat 10 Pro

    I created a form in Acrobat 10 Pro with an EMail button. The problem is, when it sends the email, it sends a complet copy of the form in editable format. All I want it to send is what the form would look like when you print it and not be able to edit

  • XSAN Server

    Hello, I currently have an XSAN Server that connects all our computers to the network. I have a external hard drive (for Archive Purpose) connected to the Server throught fire wire. The problem I am running into is sharing the External Drive so all t

  • Route add/delete broke my networking

    I have run into a networking problem on my cluster, and I cannot figure out what changed. I had a cluster configured and working.  Its access network is 192.168.10.0/24.  I have other networks, including a node management network on 10.29.130.0/24.