Sum(ai.  INVOICE_AMOUNT ),sum(ai. AMOUNT_PAID)

hi
i have this query with me ,i require require sum(ai. INVOICE_AMOUNT ),sum(ai. AMOUNT_PAID)
SELECT TRUNC (ai.gl_date), gcc.segment1, gcc.segment2,
       aca.amount paymentamount, aca.vendor_name suppliername,
       aca.check_date paymentdate, ai.invoice_num, ai.invoice_currency_code,
       aipa.accounting_date, aipa.invoice_id, ai.vendor_id, ai.amount_paid,
       ai.invoice_amount, ai.invoice_date, ai.invoice_type_lookup_code,
       pv.vendor_name
  FROM ap_invoices_all ai,
       po_vendors pv,
       ap_invoice_payments_all aipa,
       ap_checks_all aca,
       gl_code_combinations gcc
WHERE ai.vendor_id = pv.vendor_id
   AND aca.vendor_id = ai.vendor_id
   AND aipa.check_id = aca.check_id
   AND aipa.invoice_id = ai.invoice_id
   AND ai.accts_pay_code_combination_id = gcc.code_combination_id and aipa.check_id=aca.check_id
               and aipa.invoice_id=ai.invoice_id
               and ai.ACCTS_PAY_CODE_COMBINATION_ID=gcc.CODE_COMBINATION_IDi require sum(ai. INVOICE_AMOUNT ),sum(ai. AMOUNT_PAID)
i tried
SELECT   TRUNC (ai.gl_date), gcc.segment1, gcc.segment2,
         aca.amount paymentamount, aca.vendor_name suppliername,
         aca.check_date paymentdate, ai.invoice_num, ai.invoice_currency_code,
         aipa.accounting_date, aipa.invoice_id, ai.vendor_id, ai.amount_paid,
         ai.invoice_amount, ai.invoice_date, ai.invoice_type_lookup_code,
         pv.vendor_name, SUM (ai.invoice_amount), SUM (ai.amount_paid)
    FROM ap_invoices_all ai,
         po_vendors pv,
         ap_invoice_payments_all aipa,
         ap_checks_all aca,
         gl_code_combinations gcc
   WHERE ai.vendor_id = pv.vendor_id
     AND aca.vendor_id = ai.vendor_id
     AND aipa.check_id = aca.check_id
     AND aipa.invoice_id = ai.invoice_id
     AND ai.accts_pay_code_combination_id = gcc.code_combination_id
GROUP BY TRUNC (ai.gl_date),
         gcc.segment1,
         gcc.segment2,
         aca.amount,
         aca.vendor_name,
         aca.check_date,
         ai.invoice_num,
         ai.invoice_currency_code,
         aipa.accounting_date,
         aipa.invoice_id,
         ai.vendor_id,
         ai.invoice_date,
         ai.invoice_type_lookup_code,
         pv.vendor_name,
         ai.amount_paid,
         ai.invoice_amountbut since in the group by all fields are taken the proper sum doesnt come
the output comes as follows
amount paid invoice amount  sum(amountpaid) sum (invoice amount)
75                87                         75                       87
89                100                      89                      100kindly help
Edited by: makdutakdu on Oct 17, 2010 3:09 PM
Edited by: makdutakdu on Oct 17, 2010 3:29 PM

Hi,
When you run the following query what is the output you get and what output you expect?
SELECT TRUNC(ai.gl_date),
       gcc.segment1,
       gcc.segment2,
       aca.amount paymentamount,
       aca.vendor_name suppliername,
       aca.check_date paymentdate,
       ai.invoice_num,
       ai.invoice_currency_code,
       aipa.accounting_date,
       aipa.invoice_id,
       ai.vendor_id,
       ai.invoice_date,
       ai.invoice_type_lookup_code,
       pv.vendor_name,
       SUM(ai.invoice_amount),
       SUM(ai.amount_paid)
  FROM ap_invoices_all         ai,
       po_vendors              pv,
       ap_invoice_payments_all aipa,
       ap_checks_all           aca,
       gl_code_combinations    gcc
WHERE ai.vendor_id = pv.vendor_id
   AND aca.vendor_id = ai.vendor_id
   AND aipa.check_id = aca.check_id
   AND aipa.invoice_id = ai.invoice_id
   AND ai.accts_pay_code_combination_id = gcc.code_combination_id
GROUP BY TRUNC(ai.gl_date),
          gcc.segment1,
          gcc.segment2,
          aca.amount,
          aca.vendor_name,
          aca.check_date,
          ai.invoice_num,
          ai.invoice_currency_code,
          aipa.accounting_date,
          aipa.invoice_id,
          ai.vendor_id,
          ai.invoice_date,
          ai.invoice_type_lookup_code,
          pv.vendor_nameRegards,
Bhushan

Similar Messages

  • Payables report QUERY

    HI
    I NEED TO GET THE QUERY THE QUERY OF REPORT LIST OF OPEN ACCOUNTS BALANCE,
    I searched the forums but have not found anything,
    IS A REPORT OF ACCOUNTS PAYABLE AND MUST Bring me 8 SEGMENTS OF THE ACCOUNTS OF GL_CODE_COMBINATIONS TABLE WITH BALANCE ACCOUNTING, ORIGINAL AMOUNT AND rEMAINING AMOUNT
    FOR EXAMPLE, This is the report generated and which need to get the query that I bring these values
    Definición de Informe: GFE_BALANCE
    Origen de Asiento: Cuentas a Pagar
    Fecha Inicial: 1/06/2012
    A Partir de: 30/06/2012
    Cuenta Saldo Contable Importe Original Importe Restante
    (account) (balancing) (original amount) (remaining)
    16-042-2001-2601-0000-00-0000-000 34058564.10 3494865.77 -2949034.67
    16-050-2001-2601-0000-00-0000-000 37814992.82 0.00 -2392616.50
    I apologize for my English as I can, I hope I helped.

    I need to get the query to the information of the report "Open Account Balances Listing" module AP
    I use version 12 of the eBusinees Suite
    Right now I found the query to get the original amount my but I do not get Remaining Amount
    my query is
    SELECT gcc.segment1
    || '-'
    || gcc.segment2
    || '-'
    || gcc.segment3
    || '-'
    || gcc.segment4
    || '-'
    || gcc.segment5
    || '-'
    || gcc.segment6
    || '-'
    || gcc.segment7
    || '-'
    || gcc.segment8 ACCOUNT,
    Pov.Vendor_Name,
    Pos.Vendor_Site_Code,
    Api.Invoice_Num,
    Api.Terms_Date,
    Apt.Name,
    Aps.Due_Date,
    Aps.Amount_Remaining "cantidad restante",
    Api.Invoice_Amount monto_factura,
    Api.amount_paid monto_pagado,
    Api.discount_amount_taken
    FROM
    Ap_Invoices_All Api,
    Ap_Payment_Schedules_All Aps,
    Ap_Suppliers Pov,
    Ap_Supplier_Sites_All Pos,
    Ap_Terms Apt,
    xla.xla_transaction_entities xte,
    gl_code_combinations gcc,
    (SELECT tb.code_combination_id,
    NVL (tb.applied_to_entity_id, tb.source_entity_id) entity_id,
    SUM (NVL (tb.acctd_rounded_cr, 0)),
    SUM (NVL (tb.acctd_rounded_dr, 0)),
    SUM (NVL (tb.acctd_rounded_cr, 0))
    - SUM (NVL (tb.acctd_rounded_dr, 0)) diff,
    party_id
    FROM xla_trial_balances tb
    WHERE tb.definition_code ='GFE_BALANCE'
    GROUP BY tb.code_combination_id,
    NVL (tb.applied_to_entity_id, tb.source_entity_id),
    tb.party_id
    HAVING SUM (NVL (tb.acctd_rounded_cr, 0)) <>
    SUM (NVL (tb.acctd_rounded_dr, 0))) tb
    Where tb.entity_id = xte.entity_id
    AND xte.source_id_int_1 = Api.invoice_id
    And Api.Invoice_Id = Aps.Invoice_Id
    And Api.Vendor_Id = Pov.Vendor_Id
    And Api.Vendor_Site_Id = Pos.Vendor_Site_Id
    And Api.Terms_Id = Apt.Term_Id
    AND tb.code_combination_id = gcc.code_combination_id
    And Nvl(Aps.Amount_Remaining, 0) != 0
    And Api.Org_Id = :p_org_id--130
    And Api.INVOICE_DATE Between '01/06/2012' And '30/06/2012'
    And Api.Vendor_Id = Nvl('p_id_proveedor', Api.Vendor_Id)
    And Pov.Vendor_Type_Lookup_Code = Nvl('MERCANCIA', Pov.Vendor_Type_Lookup_Code)
    If anyone knows how to get the Remaining Amount would greatly appreciate it

  • Strange error in Discoverer calculated columns.

    Hi,
    I got a strange error in discoverer10g worksheet. In woksheet the calculated coulmns did not return data but in PL/SQL developer when I run the query taking from the Show SQL of Discoverer Worksheet it returns. Anyone please help me to resolve this problem.
    I paste the show sql discoverer query below:
    SELECT /*+ NOREWRITE */
    O378524.NAME AS E394898,
    O397424.COMPANY AS E397430,
    O397424.SEGMENT1 AS E397431,
    O397424.INV_ORG AS E397433,
    O397424.VENDOR_NAME AS E397435,
    O397424.INVOICE_ID AS E397436,
    O397424.PERIOD_NAME AS E397438,
    O397424.AMOUNT_PAID AS E397439,
    DENSE_RANK() OVER(PARTITION BY O397424.ORG_ID ORDER BY O397424.AMOUNT_PAID DESC) AS C_5,
    (SUM(O397424.AMOUNT_PAID)
    OVER(PARTITION BY O397424.ORG_ID ORDER BY O397424.AMOUNT_PAID DESC ROWS
    UNBOUNDED PRECEDING)) /
    (SUM(O397424.AMOUNT_PAID) OVER(PARTITION BY O397424.ORG_ID)) AS C_4,
    SUM(O397424.AMOUNT_PAID) OVER(PARTITION BY O397424.ORG_ID ORDER BY O397424.AMOUNT_PAID DESC ROWS UNBOUNDED PRECEDING) AS C_1,
    O397424.AMOUNT_PAID /
    (SUM(O397424.AMOUNT_PAID) OVER(PARTITION BY O397424.ORG_ID)) AS C_3,
    SUM(O397424.AMOUNT_PAID) OVER(PARTITION BY O397424.ORG_ID) AS C_2
    FROM (SELECT * FROM APPS.HR_OPERATING_UNITS) O378524,
    (SELECT DISTINCT /*SEGMENT1*/ CODE_COMBINATION_ID, INV_ORG
    FROM (SELECT GCC.SEGMENT1,
    GCC.CODE_COMBINATION_ID,
    DECODE(GCC.SEGMENT1,
    7590,
    'Kanowna Belle Organisation',
    7060,
    'Darlot Organisation',
    7260,
    'Cowal Organisation',
    7570,
    'Kanowna Belle Organisation',
    7595,
    'Kundana Organisation',
    7070,
    'Lawlers Organisation',
    7180,
    'NULL for Yilgarn(Barrick (Services) Limited)',
    7541,
    'Granny Smith Organisation',
    7015,
    'NULL for Barrick Gold(Barrick (Australia Pacific) Limited)',
    7610,
    'Kundana Organisation',
    7014,
    'NULL for Yilgarn(Yilgarn Shared Services)',
    7538,
    'Granny Smith Organisation',
    'Unknown') INV_ORG
    FROM APPS.GL_CODE_COMBINATIONS GCC)
    /*WHERE SEGMENT1 IN
    (7590, 7060, 7260, 7570, 7595, 7070, 7180, 7541, 7015, 7610, 7014, 7538)*/
    ) O394875,
    (SELECT CHQ.ORG_ID,
    FVT.DESCRIPTION COMPANY,
    GCC.SEGMENT1,
    INVD.DIST_CODE_COMBINATION_ID,
    DECODE(GCC.SEGMENT1,
    7590,
    'Kanowna Belle Organisation',
    7060,
    'Darlot Organisation',
    7260,
    'Cowal Organisation',
    7570,
    'Kanowna Belle Organisation',
    7595,
    'Kundana Organisation',
    7070,
    'Lawlers Organisation',
    7180,
    'NULL for Yilgarn(Barrick (Services) Limited)',
    7541,
    'Granny Smith Organisation',
    7015,
    'NULL for Barrick Gold(Barrick (Australia Pacific) Limited)',
    7610,
    'Kundana Organisation',
    7014,
    'NULL for Yilgarn(Yilgarn Shared Services)',
    7538,
    'Granny Smith Organisation',
    'Unknown') INV_ORG,
    CHQ.VENDOR_ID,
    CHQ.VENDOR_NAME,
    COUNT(INV.INVOICE_ID) INVOICE_ID,
    --INVL.PRODUCT_TYPE,
    INVL.PERIOD_NAME,
    --chq.check_date,
    SUM(NVL(INVP.PAYMENT_BASE_AMOUNT, INVP.AMOUNT)) AMOUNT_PAID
    FROM APPS.AP_CHECKS_ALL CHQ,
    APPS.AP_INVOICE_PAYMENTS_ALL INVP,
    APPS.AP_INVOICES_ALL INV,
    APPS.AP_INVOICE_LINES_ALL INVL,
    APPS.AP_INVOICE_DISTRIBUTIONS_ALL INVD,
    APPS.GL_CODE_COMBINATIONS GCC,
    APPS.FND_FLEX_VALUES FV,
    APPS.FND_FLEX_VALUES_TL FVT
    WHERE CHQ.CHECK_ID = INVP.CHECK_ID
    AND INVP.INVOICE_ID = INV.INVOICE_ID
    AND INVL.INVOICE_ID = INV.INVOICE_ID
    AND INVL.LINE_NUMBER =
    (SELECT MIN(LINE_NUMBER)
    FROM APPS.AP_INVOICE_LINES_ALL
    WHERE INVOICE_ID = INVL.INVOICE_ID
    AND LINE_TYPE_LOOKUP_CODE = 'ITEM'
    AND DISCARDED_FLAG = 'N')
    AND INVL.INVOICE_ID = INVD.INVOICE_ID
    AND INVL.LINE_NUMBER = INVD.INVOICE_LINE_NUMBER
    AND INVD.DISTRIBUTION_LINE_NUMBER = 1
    AND INVD.DIST_CODE_COMBINATION_ID = GCC.CODE_COMBINATION_ID
    AND FV.FLEX_VALUE_SET_ID = 1013043
    AND FV.FLEX_VALUE = GCC.SEGMENT1
    AND FV.FLEX_VALUE_ID = FVT.FLEX_VALUE_ID
    GROUP BY CHQ.ORG_ID,
    GCC.SEGMENT1,
    CHQ.VENDOR_ID,
    CHQ.VENDOR_NAME,
    FVT.DESCRIPTION,
    --INVL.PRODUCT_TYPE,
    INVL.PERIOD_NAME,
    --chq.check_date,
    INVD.DIST_CODE_COMBINATION_ID) O397424
    WHERE ((O397424.ORG_ID = O378524.ORGANIZATION_ID) AND
    (O397424.DIST_CODE_COMBINATION_ID = O394875.CODE_COMBINATION_ID))
    AND (O397424.AMOUNT_PAID > 0)
    AND (O397424.PERIOD_NAME = /*:"Period"*/'DEC-09')
    -- AND (O394875.INV_ORG = :"Inv Org")
    AND (O378524.NAME = /*:OU*/'Barrick Yilgarn')
    ORDER BY O397424.AMOUNT_PAID DESC;
    Edited by: Soma Sekhar D on Feb 24, 2010 11:46 AM

    Hi,
    In the report I have two worksheet. The Ist worksheet has the same calculated columns as 2nd worksheet. Even the calculations are also the same. The only difference is I use different folder for the 2nd worksheet. For 2nd worksheet layout only the calculated columns will not display the result.The other columns displayed the result properly. Even in the Ist worksheet all the columns including calculated columns displayed the result correctly.The calculations are same in the 2nd worsheet with calculation names different and items coming from different folder. As these calculations are working properly in Ist worksheet,why its not appearing in the 2nd worksheet? The query I paste before is the Discoverer show sql query for 2nd worksheet.
    Please help.

  • Reconciled invoices are coming in the report

    Before changes
    SELECT 'FINANCE' detdepartment, 'FINANCE' detsub_dept, 'FINANCE' detuser_name,
           ai.unique_remittance_identifier, ai.invoice_num, ai.invoice_date,
           ai.description, ai.invoice_amount, av.vendor_name, av.vendor_type_disp,
           ai.invoice_received_date, TRUNC (aipa.creation_date) last_forward_date,
           TRUNC (xvd.creation_date + NVL (atl.due_days, 0)) due_date,
           trunc(sysdate)-(TRUNC(xvd.CREATION_DATE)+NVL(atl.DUE_DAYS,0))due_days,
           'Validated - Oracle Paid: Unclear' status, ai.invoice_id,
           (SELECT RTRIM
                      (XMLAGG (XMLELEMENT (e, pha.segment1 || '|')).EXTRACT
                                                                       ('//text()'),
                       '|'
              FROM po_headers_all pha, ap_invoice_lines_all aila
             WHERE pha.po_header_id = aila.po_header_id
               AND aila.invoice_id = ai.invoice_id) po_number,
           (SELECT RTRIM
                      (XMLAGG (XMLELEMENT (e, pha.type_lookup_code || '|')).EXTRACT
                                                                       ('//text()'),
                       '|'
              FROM po_headers_all pha, ap_invoice_lines_all aila
             WHERE pha.po_header_id = aila.po_header_id
               AND aila.invoice_id = ai.invoice_id) po_type,
           (SELECT RTRIM
                      (XMLAGG (XMLELEMENT (e, pra.release_num || '|')).EXTRACT
                                                                       ('//text()'),
                       '|'
              FROM po_releases_all pra, ap_invoice_lines_all aila
             WHERE pra.po_release_id = aila.po_release_id
               AND aila.invoice_id = ai.invoice_id) release_number
      FROM apps.ap_terms apt,
           ap_invoices_all ai,
           ap_terms_lines atl,
           org_organization_definitions ood,
           fnd_user fu,
           xxindus_vhd_dynamic_h xvdh,
           xxindus_vhd_dynamic xvd,
           ap_lookup_codes alc,
           ap_invoice_payments_all aipa,
           ap_payment_history_all apha,
           ap_vendors_v av
    WHERE xvd.invoice_id = ai.invoice_id
       AND apt.term_id = ai.terms_id
       AND apt.term_id = atl.term_id
       AND atl.sequence_num = 1
       AND ai.terms_id = apt.term_id
       AND ai.org_id = ood.organization_id
       AND ai.created_by = fu.user_id
       AND ai.invoice_id = xvdh.invoice_id
       AND ai.invoice_id = xvd.invoice_id
       AND alc.lookup_code = ai.invoice_type_lookup_code
       AND ai.invoice_id = aipa.invoice_id
       AND aipa.check_id = apha.check_id
       AND aipa.invoice_payment_id = (SELECT MAX (invoice_payment_id)
                                        FROM ap_invoice_payments_all a
                                       WHERE a.invoice_id = ai.invoice_id)
       AND apha.accounting_event_id = (SELECT MAX (accounting_event_id)
                                         FROM ap_payment_history_all aph1
                                        WHERE aph1.check_id = apha.check_id)
       AND ai.vendor_id = av.vendor_id
       AND apha.transaction_type IN ('PAYMENT CREATED', 'PAYMENT UNCLEARING')
       AND ai.invoice_type_lookup_code = 'STANDARD'
       AND alc.lookup_type = 'INVOICE TYPE'
       AND alc.enabled_flag = 'Y'
       AND ai.wfapproval_status IN ('WFAPPROVED', 'MANUALLY APPROVED')
       AND xvdh.checked = 'Y'
       AND xvd.status = 'Sent to Finance'
       AND ai.cancelled_date IS NULL
       --- AND SYSDATE BETWEEN fu.start_date AND NVL(fu.end_date,SYSDATE)
       AND ai.invoice_amount =
                    NVL ((ai.amount_paid + NVL (ai.discount_amount_taken, 0)), 0)
    --   AND ood.organization_name = :p_org_name
       AND ood.organization_id = :p_org_id
       AND ai.invoice_received_date
              BETWEEN NVL (TRUNC (TO_DATE (:p_from_date, 'RRRR/MM/DD HH24:MI:SS')),
                           ai.invoice_received_date
                  AND NVL (TRUNC (TO_DATE (:p_to_date, 'RRRR/MM/DD HH24:MI:SS')),
                           SYSDATE
       AND (fu.user_name LIKE '%VHD%' OR fu.description = 'VHD')
    after changes
    SELECT 'FINANCE' detdepartment, 'FINANCE' detsub_dept, 'FINANCE' detuser_name,
           ai.unique_remittance_identifier, ai.invoice_num, ai.invoice_date,
           ai.description, ai.invoice_amount, av.vendor_name, av.vendor_type_disp,
           ai.invoice_received_date, TRUNC (aipa.creation_date) last_forward_date,
           TRUNC (xvd.creation_date + NVL (atl.due_days, 0)) due_date,
           trunc(sysdate)-(TRUNC(xvd.CREATION_DATE)+NVL(atl.DUE_DAYS,0))due_days,
           'Validated - Oracle Paid: Unclear' status, ai.invoice_id,
           (SELECT RTRIM
                      (XMLAGG (XMLELEMENT (e, pha.segment1 || '|')).EXTRACT
                                                                       ('//text()'),
                       '|'
              FROM po_headers_all pha, ap_invoice_lines_all aila
             WHERE pha.po_header_id = aila.po_header_id
               AND aila.invoice_id = ai.invoice_id) po_number,
           (SELECT RTRIM
                      (XMLAGG (XMLELEMENT (e, pha.type_lookup_code || '|')).EXTRACT
                                                                       ('//text()'),
                       '|'
              FROM po_headers_all pha, ap_invoice_lines_all aila
             WHERE pha.po_header_id = aila.po_header_id
               AND aila.invoice_id = ai.invoice_id) po_type,
           (SELECT RTRIM
                      (XMLAGG (XMLELEMENT (e, pra.release_num || '|')).EXTRACT
                                                                       ('//text()'),
                       '|'
              FROM po_releases_all pra, ap_invoice_lines_all aila
             WHERE pra.po_release_id = aila.po_release_id
               AND aila.invoice_id = ai.invoice_id) release_number
      FROM apps.ap_terms apt,
           ap_invoices_all ai,
           ap_terms_lines atl,
           org_organization_definitions ood,
           fnd_user fu,
           xxindus_vhd_dynamic_h xvdh,
           xxindus_vhd_dynamic xvd,
           ap_lookup_codes alc,
           ap_invoice_payments_all aipa,
           ap_payment_history_all apha,
           ap_vendors_v av
    WHERE xvd.invoice_id = ai.invoice_id
       AND apt.term_id = ai.terms_id
       AND apt.term_id = atl.term_id
       AND atl.sequence_num = 1
       AND ai.terms_id = apt.term_id
       AND ai.org_id = ood.organization_id
       AND ai.created_by = fu.user_id
       AND ai.invoice_id = xvdh.invoice_id
       AND ai.invoice_id = xvd.invoice_id
       AND alc.lookup_code = ai.invoice_type_lookup_code
       AND ai.invoice_id = aipa.invoice_id
       AND aipa.check_id = apha.check_id
        AND aipa.invoice_payment_id = (SELECT MAX (invoice_payment_id)
                                        FROM ap_invoice_payments_all a
                                       WHERE a.invoice_id = ai.invoice_id)
                                        group by a.transaction_type)                                  
       AND apha.accounting_event_id = (SELECT MAX (accounting_event_id)
                                         FROM ap_payment_history_all aph1
                                        WHERE aph1.check_id = apha.check_id)
       AND ai.vendor_id = av.vendor_id
       AND apha.transaction_type IN ('PAYMENT CREATED', 'PAYMENT UNCLEARIN\G')
       and not exists ( select 1
                        from   apps.ap_payment_history_all apha
                             ,apps.ap_invoice_payments_all aipa
                             ,apps.ap_invoices_all  ai1
                        where aipa.check_id = apha.check_id
                        and ai1.invoice_id = aipa.invoice_id
                        and ai1.INVOICE_ID=ai.invoice_id
                        and apha.transaction_type IN ('PAYMENT CLEARING')
                        and  apha.CREATION_DATE = ( select max(apha.CREATION_DATE)
                                                    from apps.ap_payment_history_all apha
                                                        ,apps.ap_invoice_payments_all aipa
                                                        ,apps.ap_invoices_all  ai2
                                                    where aipa.check_id = apha.check_id
                                                    and ai2.invoice_id = aipa.invoice_id
                                                    and ai2.INVOICE_ID=ai.INVOICE_ID
                      ) ---- newly added
       AND ai.invoice_type_lookup_code = 'STANDARD'
       AND alc.lookup_type = 'INVOICE TYPE'
       AND alc.enabled_flag = 'Y'
       AND ai.wfapproval_status IN ('WFAPPROVED', 'MANUALLY APPROVED')
       AND xvdh.checked = 'Y'
       AND xvd.status = 'Sent to Finance'
       AND ai.cancelled_date IS NULL
       --- AND SYSDATE BETWEEN fu.start_date AND NVL(fu.end_date,SYSDATE)
       AND ai.invoice_amount =
                    NVL ((ai.amount_paid + NVL (ai.discount_amount_taken, 0)), 0)
    --   AND ood.organization_name = :p_org_name
       AND ood.organization_id = :p_org_id
      - AND AI.INVOICE_NUM='A302689/EXM/OSR/03-2012'
       AND ai.invoice_received_date
              BETWEEN NVL (TRUNC (TO_DATE (:p_from_date, 'RRRR/MM/DD HH24:MI:SS')),
                           ai.invoice_received_date
                  AND NVL (TRUNC (TO_DATE (:p_to_date, 'RRRR/MM/DD HH24:MI:SS')),
                           SYSDATE
       AND (fu.user_name LIKE '%VHD%' OR fu.description = 'VHD')

    Hi karthick,
    Reconciled invoices are coming in the Report , some  invoice are coming in the repot if i use the following condition the invoice are not comming in the report   please advice  wheather i can use this condition are not
    and not exists ( select 1
                        from   apps.ap_payment_history_all apha
                             ,apps.ap_invoice_payments_all aipa
                             ,apps.ap_invoices_all  ai1
                        where aipa.check_id = apha.check_id
                        and ai1.invoice_id = aipa.invoice_id
                        and ai1.INVOICE_ID=ai.invoice_id
                        and apha.transaction_type IN ('PAYMENT CLEARING')
                        and  apha.CREATION_DATE = ( select max(apha.CREATION_DATE)
                                                    from apps.ap_payment_history_all apha
                                                        ,apps.ap_invoice_payments_all aipa
                                                        ,apps.ap_invoices_all  ai2
                                                    where aipa.check_id = apha.check_id
                                                    and ai2.invoice_id = aipa.invoice_id
                                                    and ai2.INVOICE_ID=ai.INVOICE_ID
    Thanks,
    Naresh

  • How to add balance column in the PO and AP Report

    I have added amount remaining column in this report from ap payment schedules all,but it is not returning any rows,can you please look into this issue.
    select
    distinct po_vendors.segment1
    || chr(9) || po_vendors.vendor_name
    || chr(9) || po_vendor_sites.vendor_site_code
    || chr(9) || po_vendors.vendor_type_lookup_code
    || chr(9) || po_vendor_sites. attribute2
    || chr(9) || po_vendor_sites.inactive_date
    || chr(9) || po_vendor_sites.creation_date
    || chr(9) || to_char(max(ap_checks.check_date), 'DD-MON-YYYY')
    || chr(9) || ap_payment_schedules.amount_remaining
    from
    po_vendors
    ,po_vendor_sites
    ,ap_checks
    ,ap_payment_schedules
    ,ap_invoices i2
    where
    po_vendors.end_date_active is null and
    po_vendors.vendor_id = po_vendor_sites.vendor_id
    -- and po_vendors.VENDOR_ID=i2.VENDOR_ID
    and i2.invoice_id=ap_payment_schedules.invoice_id
    and po_vendor_sites.inactive_date is null
    and po_vendor_sites.creation_date < sysdate--&v_cutoff_date
    and po_vendor_sites.pay_site_flag = 'Y'
    and not exists (select vendor_site_id from ap_checks c2 where
    c2.vendor_site_id = po_vendor_sites.vendor_site_id
    and c2.check_date < sysdate)--&v_cutoff_date)
    and not exists (select vendor_site_id from ap_invoices i2 where
    i2.vendor_site_id = po_vendor_sites.vendor_site_id
    and (i2.invoice_date < sysdate or payment_status_flag in ('N', 'P') ) )
    and po_vendor_sites.vendor_site_id = ap_checks.vendor_site_id (+)
    --and ((i2.invoice_amount) - (i2.amount_paid)) <>0
    --and (i2.invoice_amount - NVL(i2.amount_paid,0))>=0
    group by
    po_vendors.segment1
    ,po_vendors.VENDOR_ID
    ,po_vendors.vendor_name
    ,po_vendor_sites.vendor_site_code
    ,po_vendors.vendor_type_lookup_code
    ,po_vendor_sites.attribute2
    ,po_vendor_sites.inactive_date
    ,po_vendor_sites.creation_date
    --,i2.invoice_amount,i2.amount_paid
    --,i2.invoice_num
    ,po_vendor_sites.VENDOR_SITE_ID
    ,ap_payment_schedules.amount_remaining
    --,(i2.invoice_amount-nvl(i2.amount_paid,0))
    --order by
    --     po_vendors.vendor_name
    ---     ,po_vendors.segment1
    --     ,po_vendor_sites.vendor_site_code

    Hi,
    Thanks a lot, it's really help...don't know why I didn't see this customized point before in SPRO.
    But I have an other issue, my new fields is added in the CATS screen and now I'm trying to put default value by using the user exit of extension CATS0009.
    When I complete the value of my new fields in structure CATSD_IMP, there are not taking into account and the CATS screen doesn't display the value.
    Am I using the wrong table ? wrong user-exit ? or my code ..
    Thansk a lot again for your help.
    Fanny GROUX

  • Inline Query Sum

    hi
    i am using 2 inline queries, from both queries am getting values in outer query
    i need to find out the sum of amount total.
    here is the query
    select  customer_name,branch, round((revenue)/100000,2) revenue,round(((sum(revenue)- sum(ap_amount))/100000),2) margin, (sum(revenue)- sum(ap_amount))/sum(revenue) as "Margin %" from
    (select                 'AP' Mod,
                            fvv.description branch,
                            glc.segment4 ap_won,
                            sum(aida.amount) ap_amount                          
                           FROM
                            apps.ap_invoice_distributions_all aida,
                            apps.ap_invoices_all aia,
                            apps.fnd_flex_values_vl fvv,
                            apps.gl_code_combinations glc,
                            apps.po_vendors pv
                         WHERE aia.invoice_id = aida.invoice_id
                         AND aida.dist_code_combination_id = glc.code_combination_id
                         AND pv.vendor_id = aia.vendor_id
                         AND aida.set_of_books_id = pv.set_of_books_id
                         AND aia.set_of_books_id = aida.set_of_books_id
                         AND aia.set_of_books_id = 2
                         AND glc.segment4 != '0000000'
                         AND aia.org_id = aida.org_id
                         AND aia.org_id = 92
                         AND aida.posted_flag = 'Y'
                         AND glc.segment2 = fvv.flex_value
                         AND fvv.flex_value_set_id = 1008015
                         AND aida.accounting_date between '01-jun-2010' and '10-jun-2010'
                         AND aia.invoice_amount != 0
                        and glc.SEGMENT1=16
                        group by
                           fvv.description,
                           glc.segment4
                            order by 2)a,
    (SELECT                 
                            'AR' Mod,
                            rc.CUSTOMER_NAME customer_name,
                            rct.interface_header_attribute1 ar_won,
                            sum(rctl.extended_AMOUNT) revenue,
                            fvv.description branch1   
                        FROM apps.ra_customer_trx_lines_all rctl,
                            apps.RA_CUST_TRX_LINE_GL_DIST_ALL rctg,
                            apps.fnd_flex_values_vl fvv,
                            apps.ra_customer_trx_all rct,
                            apps.ra_customers rc,
                            apps.RA_CUST_TRX_TYPES_ALL rctt,
                            apps.gl_code_combinations gcc
                      WHERE rctl.customer_trx_id = rct.customer_trx_id
                        and rct.BILL_TO_CUSTOMER_ID=rc.CUSTOMER_ID
                        and rct.CUSTOMER_TRX_ID=rctg.CUSTOMER_TRX_ID
                        and rctl.CUSTOMER_TRX_LINE_ID=rctg.CUSTOMER_TRX_LINE_ID
                        and rctt.CUST_TRX_TYPE_ID = rct.CUST_TRX_TYPE_ID
                        and gcc.CODE_COMBINATION_ID=rctg.CODE_COMBINATION_ID
                        AND gcc.segment2 = fvv.flex_value
                        AND fvv.flex_value_set_id = 1008015
                        and gcc.SEGMENT3 like '5%'
                        and rctg.ACCOUNT_CLASS='REV' 
                        and rctl.line_type =  'LINE'
                        and rct.complete_flag='Y'
                        and rctg.gl_date between '01-jun-2010' and '10-jun-2010'
                        and rct.ORG_ID=92
                        group by fvv.description,rct.interface_header_attribute1,rc.CUSTOMER_NAME
                        order by 2)b
    where a.ap_won=b.ar_won
    and a.branch = b.branch1
    group by branch,revenue,customer_name
    order by 2  I need to revenue total,
    can you let me know, how to calculate that.
    Thanks,

    Like this:
    select  customer_name,branch, round((revenue)/100000,2) revenue,
            round(((sum(revenue)- sum(ap_amount))/100000),2) margin,
            (sum(revenue)- sum(ap_amount))/sum(revenue) as "Margin %",
            SUM(revenue) OVER() tot_Rev from
    (select                 'AP' Mod,
                            fvv.description branch,
                            glc.segment4 ap_won,
                            sum(aida.amount) ap_amount                          
                           FROM
                            apps.ap_invoice_distributions_all aida,
                            apps.ap_invoices_all aia,
                            apps.fnd_flex_values_vl fvv,
                            apps.gl_code_combinations glc,
                            apps.po_vendors pv
                         WHERE aia.invoice_id = aida.invoice_id
                         AND aida.dist_code_combination_id = glc.code_combination_id
                         AND pv.vendor_id = aia.vendor_id
                         AND aida.set_of_books_id = pv.set_of_books_id
                         AND aia.set_of_books_id = aida.set_of_books_id
                         AND aia.set_of_books_id = 2
                         AND glc.segment4 != '0000000'
                         AND aia.org_id = aida.org_id
                         AND aia.org_id = 92
                         AND aida.posted_flag = 'Y'
                         AND glc.segment2 = fvv.flex_value
                         AND fvv.flex_value_set_id = 1008015
                         AND aida.accounting_date between '01-jun-2010' and '10-jun-2010'
                         AND aia.invoice_amount != 0
                        and glc.SEGMENT1=16
                        group by
                           fvv.description,
                           glc.segment4
                            order by 2)a,
    (SELECT                 
                            'AR' Mod,
                            rc.CUSTOMER_NAME customer_name,
                            rct.interface_header_attribute1 ar_won,
                            sum(rctl.extended_AMOUNT) revenue,
                            fvv.description branch1   
                        FROM apps.ra_customer_trx_lines_all rctl,
                            apps.RA_CUST_TRX_LINE_GL_DIST_ALL rctg,
                            apps.fnd_flex_values_vl fvv,
                            apps.ra_customer_trx_all rct,
                            apps.ra_customers rc,
                            apps.RA_CUST_TRX_TYPES_ALL rctt,
                            apps.gl_code_combinations gcc
                      WHERE rctl.customer_trx_id = rct.customer_trx_id
                        and rct.BILL_TO_CUSTOMER_ID=rc.CUSTOMER_ID
                        and rct.CUSTOMER_TRX_ID=rctg.CUSTOMER_TRX_ID
                        and rctl.CUSTOMER_TRX_LINE_ID=rctg.CUSTOMER_TRX_LINE_ID
                        and rctt.CUST_TRX_TYPE_ID = rct.CUST_TRX_TYPE_ID
                        and gcc.CODE_COMBINATION_ID=rctg.CODE_COMBINATION_ID
                        AND gcc.segment2 = fvv.flex_value
                        AND fvv.flex_value_set_id = 1008015
                        and gcc.SEGMENT3 like '5%'
                        and rctg.ACCOUNT_CLASS='REV' 
                        and rctl.line_type =  'LINE'
                        and rct.complete_flag='Y'
                        and rctg.gl_date between '01-jun-2010' and '10-jun-2010'
                        and rct.ORG_ID=92
                        group by fvv.description,rct.interface_header_attribute1,rc.CUSTOMER_NAME
                        order by 2)b
    where a.ap_won=b.ar_won
    and a.branch = b.branch1
    group by branch,revenue,customer_name
    order by 2

  • I want a select statement to return two values, sum of one column and customer number

    I have two columns one called invoice_number and the other invoice_amount. I want a select statement to return two columns.... invoice_number and then the sum of the invoice_amount(s) for each unique invoice number.
    SELECT sum(invoice_amount) AS Totalinvoice_amount FROM InvoiceTB where invoice_number = 'INV102'
    This is where I've started, which returns:
    Totalinvoice_amount
    500.00
    Any help is appreciated.
    Please mark my post as helpful or the answer or better yet.... both! :) Thanks!

    Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. Temporal data should
    use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect. 
    This is minimal polite behavior on SQL forums. 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • IF statement in Calculated Field for Share point, doesnt calculate sum in my Excel Pivot table.

    Hi Everyone
    I used this in SP calculated column field.
    =IF([Shift Sched]="1pm to 10pm","0",IF([Shift Sched]="2pm to 11pm","1",IF([Shift Sched]="3pm to 12am","2",IF([Shift Sched]="4pm to 1am","3",IF([Shift Sched]="5pm to 2am","4",IF([Shift
    Sched]="6pm to 3am","5",IF([Shift Sched]="7pm to 4am","6",IF([Shift Sched]="8pm to 5am","7",IF([Shift Sched]="9pm to 6am","8",IF([Shift Sched]="10pm to 7am","8",IF([Shift
    Sched]="11pm to 8am","7",IF([Shift Sched]="12pm to 9am","6",IF([Shift Sched]="1am to 10am","5",IF([Shift Sched]="2am to 11am","4",IF([Shift Sched]="3am to 12pm","3",IF([Shift
    Sched]="4am to 1pm","2",IF([Shift Sched]="5am to 2pm","1",IF([Shift Sched]="6am to 3pm","0",IF([Shift Sched]="7am to 4pm","0",IF([Shift Sched]="8am to 5pm","0",IF([Shift
    Sched]="9am to 6pm","0",IF([Shift Sched]="10am to 7pm","0",IF([Shift Sched]="11am to 8pm","0",IF([Shift Sched]="12pm to 9pm","0"))))))))))))))))))))))))    
    it was able to work fine however my issue is when i extract the information to excel and use a pivot table the table is not able to calulate the sum of the value for this field. Can you please help me with this. this is for an Attendance traker for Night
    Differential pay for employees. they create a daily log of their shift schedule and if i summarize this in pivot the value in the calculated field for this is not getting the sum.
    Thanks,
    Norman

    Hi Everyone
    I used this in SP calculated column field.
    =IF([Shift Sched]="1pm to 10pm","0",IF([Shift Sched]="2pm to 11pm","1",IF([Shift Sched]="3pm to 12am","2",IF([Shift Sched]="4pm to 1am","3",IF([Shift Sched]="5pm to 2am","4",IF([Shift
    Sched]="6pm to 3am","5",IF([Shift Sched]="7pm to 4am","6",IF([Shift Sched]="8pm to 5am","7",IF([Shift Sched]="9pm to 6am","8",IF([Shift Sched]="10pm to 7am","8",IF([Shift
    Sched]="11pm to 8am","7",IF([Shift Sched]="12pm to 9am","6",IF([Shift Sched]="1am to 10am","5",IF([Shift Sched]="2am to 11am","4",IF([Shift Sched]="3am to 12pm","3",IF([Shift
    Sched]="4am to 1pm","2",IF([Shift Sched]="5am to 2pm","1",IF([Shift Sched]="6am to 3pm","0",IF([Shift Sched]="7am to 4pm","0",IF([Shift Sched]="8am to 5pm","0",IF([Shift
    Sched]="9am to 6pm","0",IF([Shift Sched]="10am to 7pm","0",IF([Shift Sched]="11am to 8pm","0",IF([Shift Sched]="12pm to 9pm","0"))))))))))))))))))))))))    
    it was able to work fine however my issue is when i extract the information to excel and use a pivot table the table is not able to calulate the sum of the value for this field. Can you please help me with this. this is for an Attendance traker for Night
    Differential pay for employees. they create a daily log of their shift schedule and if i summarize this in pivot the value in the calculated field for this is not getting the sum.
    Thanks,
    Norman

  • Discoverer  report does not sum up the column

    Hi All,
    I am running the discoverer report from discoverer desktop and was
    trying to use the sum function to sum the total amount of the report.
    The sum function does not work and it only display Cell
    Sum: (blank) with no actual data.
    When i checked the report details some columns are calculated based on the columns which i want to sum up.
    Any ideas please share with me
    Thanks in advance.

    b) What is the difference between sum and cell sum? Well, I certainly won't claim to be a Discoverer guru. From what little I have seen, the practical result is not any difference really between the two. SUM of a calculated row is adding up the calculation to the total. Whereas cell sum is like adding up the individual values behind the calculation you see. The distinction makes more sense when you have SUM DISTINCT and CELL SUM DISTINCT being involved. Then you will see a difference in the calculated total. But for SUM and CELL SUM itself, I have not seen any difference between the two, but I am still pretty new to Discoverer.
    e) Aggregate field from a folder. Well, this may be one where you have to play around with your own data to understand. Let me try to give you a simple example. Let's say you have a sales table with 100 rows. You have sales data for 5 cities, and each city has 20 rows of sales history. If you pick Sales Dollars Detail and City Name for your workbook and run, you will get 100 rows in your result (complete detail listing). So that is what happens with no aggregation. Now, instead of doing Sales Dollars Detail, you pick Sales Dollars Sum (the same thing as saying SUM(Sales Dollars) in an SQL statement). Run the workbook. You will now get 5 rows of data, instead of 100 rows of data. You will get one row for each city. If you look at the SQL that Discoverer generates, you will see that it has now done a GROUP BY in the SQL statement. Notice I have not said anything about DISTINCT (just trying to keep things simple).
    Now, lets say you do a workbook for City, Part Number, and Sales Dollars Sum. Run the workbook. You get a summarized result (say maybe 10 rows of summary data this time). If you look at the Discoverer SQL, the GROUP BY is now by city and part number, automatically doing that because you picked the SUM version of sales dollars.
    Now lets say you add Sales Units Detail to the workbook. Discoverer will give you a warning message that you are have both an aggregate and a non-aggregate and that you may end up with unpredictable results. Run the workbook. You will be back to 100 rows, because you specified sales units in detail.
    Most of the time I do not want to see detail rows in a workbook. So most of the time I am picking the SUM aggregate for an amount item.
    Hope this explains things a bit. Sounds like maybe you need to take the Discoverer Create Queries and Reports class. Would help you understand these things better. Good luck.
    John Dickey

  • Sum function within if/then/else (xdofx:if)

    I'm attempting to display a total at a particular group within my report. This total is conditional and should choose to display a placeholder value or the sum of another placeholder value (in a child group).
    I have been able to vary my output based on the value I want to check: FIXED_QUOTE_FLAG - I have the if/then/else working in a simplified fashion
    I can display literals and some placeholders correctlly eg. print a literal value of 00110011 or the value of placeholder QUOTED_PRICE
    I can also display a calculated placeholder, using sum within the group I am concerned with: sum (current-group()/ACTIVITY_CHRG)
    But when I try to get everythign working together ...
    I cannot get the sum to work inside the if/then/else condition. The result is NULL (blank in HTML output).
    The following is the snippet which is not working correctly:
    <?xdofx:if FIXED_QUOTE_FLAG = 'Y' then QUOTED_PRICE else sum (current-group()/ACTIVITY_CHRG) end if?>
    Message was edited by:
    gareth_adamson

    To answer you first question, perhaps sum is not a supported function in the xdofx namespace. It's annoying when this problem comes up because xdofx namespace seems to be the only way to do if then else clauses. I'm not entirely certain on the above, but you could resort to using BI Publisher's built-in if statement.
    For your problem, something like this:
    <?if: FIXED_QUOTE_FLAG='Y'?>
    QUOTED_PRICE
    <?end if?>
    <?if: FIXED_QUOTE_FLAG!='Y'?>
    <?sum(current-group()/ACTIVITY_CHRG)?>
    <?end if?>
    EDIT:
    There is a way to do if else without xdofx namespace. It is done with <?choose:?> <?when:?> and <?otherwise:?> tags. Here is example syntax copied from Tim Dexter's blog:
    <?choose:?>
    <?when:count(TRX_NUMBER) > 0?>
    Invoice Table
    <?end when?>
    <?otherwise:?>
    No Data Found
    <?end otherwise?>
    <?end choose?>
    To answer the second question about a running total, you will need to use the <?xdoxslt:set_variable($_XDOCTX,'var_name',var_value)?> and the <?xdoxslt:get_variable($_XDOCTX,'var_name')?>. This method of working with variables is the only method that allows you to update a variable. This makes it good for running totals. Consult the official user guide under "Creating an RTF Template" the section about using variables and calculating running totals.
    So, in your problem, once you get the first part working, you will have to add that value to your running total. It will look something like this:
    <?xdoxslt:set_variable($_XDOCTX,'running_total',xdoxslt:get_variable($_XDOCTX,'running_total') + conditional_value)?>
    Remember to initialize the running total to zero! Hope this helps.
    Thanks,
    Matt Soukup
    Message was edited by:
    Matt Soukup

  • Sum of LineCount Including Groups and Detail Data On Each Page Used To Generate New Page If TotalPageLineCount 28

    Post Author: tadj188#
    CA Forum: Formula
    Needed: Sum of LineCount Including Groups and Detail Data On Each Page Used To Generate New Page If TotalPageLineCount > 28
    Background:
    1) Report SQL is created with unions to have detail lines continue on a page, until it reaches page footer or report footer, rather than using  subreports.    A subreport report is now essentially a group1a, group1b, etc. (containing column headers and other data within the the report    with their respective detail lines).  I had multiple subreports and each subreport became one union.
    Created and tested, already:
    1) I have calculated @TotalLineForEachOfTheSameGroup, now I need to sum of the individual same group totals to get the total line count on a page.
    Issue:
    1) I need this to create break on a certain line before, it dribbles in to a pre-printed area.
    Other Ideas Appreciated:
    1) Groups/detail lines break inconveniently(dribble) into the pre-printed area, looking for alternatives for above situation.
    Thank you.
    Tadj

    export all image of each page try like this
    var myDoc = app.activeDocument;
    var myFolder = myDoc.filePath;
    var myImage = myDoc.allGraphics;
    for (var i=0; myImage.length>i; i++){
        app.select(myImage[i]);
        var MyImageNmae  = myImage[i].itemLink.name;
        app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.high;
        app.jpegExportPreferences.exportResolution = 300;
           app.selection[0].exportFile(ExportFormat.JPG, File(myFolder+"/"+MyImageNmae+".JPEG"), false);
        alert(myImage[i].itemLink.name)

  • How to create a sum on change of a detailed record without using groups

    Hi,
    I'm working on an overtime/payroll report.  Overtime hours are calculated based on hours worked greater than 40 within the span of Sunday to Saturday.  Further, pay periods are every two weeks and do not align with the calendar week of sunday to saturday.
    I've managed to figure out how to do the overtime calculation from sunday to saturday and then the totals for each of these calendar weeks. However, I'd also like to calculate the totals for the pay periods.  I cannot group on both the calendar week AND the pay period id because sometimes the calendar week starts before the pay period starts and sometimes the pay period starts before the calendar week. So, one is not a sub-group of the other.  I tried setting both up as groups but it, unfortunately, resets by hour calculations at the wrong point because when one group is still going the other is ending.
    So, the report is working well with just the one group - calendar week (oh, and there is a higher level group - employee id as this calculation is done for each employee). I can include the pay period id in the detail lines and I can see when it changes. So, if I could create a formula that summed the hours by pay period id and than reset when a new pay period id begins that is what I am after. I just want the sum of hours upon each change of pay period id.  I'll attempt to show what the data looks like below:
    Group 1: Employee Name (say Fred Jones)
       Group 2: Week Beginning January 8, 2012
    Date  RegularHours   OvertimeHours  PayPeriodId
    Jan 8        12                              0                            1
    Jan 9        12                              0                            1
    Jan 10      12                              0                            1
    Jan 11       4                               8                            1
    Jan 12       0                               12                          1
    Jan 13       0                               9                            1
    Jan 14       0                               6                            1
    Total      40                          35                   
    Group 2: Week Beginning January 15, 2012
    Date  RegularHours   OvertimeHours  PayPeriodId
    Jan 15      12                              0                            1
    Jan 16      12                              0                            1
    Jan 17      12                              0                            1
    Jan 18       4                               9                            2
    Jan 19       0                               10                          2
    Jan 20       0                               8                            2
    Jan 21       0                               7                            2
    Total      40                          34                   
    So, the total hours for pay period #1 should be:
    RegularHours   OvertimeHours
    76                                35
    And, the total hours for pay period #2 should be:
    RegularHours   OvertimeHours
    4                                   34
    I tried creating a formula: Distinctcount ({@OT Hours}, {Command.pay_periods_id}) but Crystal says I cannot summarize the formula that is in it.
    I'm not a programmer but it feels like a loop of some sort (For each, unique pay period id sum the OT Hours).
    Any and all help much appreciated in advance!
    Mark
    Edited by: mahewitt on Feb 14, 2012 4:42 AM

    Hi Mark,
    Here's something I have come up with:
    1) Create this formula and place it on the details section beside the PayPeriodID field.Replace in the formula with PayPeriodId, with RegularHours and with OvertimeHours.
    WhilePrintingRecords;
    numbervar array reg_hrs;
    numbervar array ot_hrs;
    numbervar array payid;
    numbervar reg;
    numbervar ot;
    numbervar x;
    numbervar y;
    if not({PayperId} in payid) then
        y := y + 1;
        redim preserve payid[y];
        payid[y] := {PayperId};
    if onlastrecord then
        reg := reg + {Regular};
        ot := ot + {Overtime};
        x := x + 1;
        redim preserve reg_hrs[x];
        redim preserve ot_hrs[x];
        reg_hrs[x] := reg;
        ot_hrs[x] := ot;
    else if {PayperId} = next({PayperId}) then
        reg := reg + {Regular};
        ot := ot + {Overtime};
    else
        reg := reg + {Regular};
        ot := ot + {Overtime};
        x := x + 1;
        redim preserve reg_hrs[x];
        redim preserve ot_hrs[x];
        reg_hrs[x] := reg;
        ot_hrs[x] := ot;
        reg := 0;
        ot := 0;
    2) Create this formula and place it on the Group Footer 1 (Employee Name group):
    WhilePrintingRecords;
    numbervar array payid;
    numbervar array reg_hrs;
    numbervar array ot_hrs;
    numbervar i;
    stringvar final;
    for i := 1 to ubound(payid) do
        final := final + "For Pay Period # "&payid<i>&chr(13)&chr(13)&"Regular Working Hours are :"&reg_hrs<i>&chr(13)&"Overtime Hours are :"&ot_hrs<i>&chr(13)&chr(13)&chr(13)
    final;
    3) Right-click this field and select Format Field > Common tab > Check the 'can grow' option and increase the horizontal size of the formula field to around 3.5 to 4'
    4) Create this formula to reset the variables at the Group Header 1. This will make sure it prints the Regular and Overtime hours for every employee:
    whileprintingrecords;
    numbervar array reg_hrs := 0;
    numbervar array ot_hrs := 0;
    numbervar array payid := 0;
    numbervar reg := 0;
    numbervar ot := 0;
    numbervar x := 0;
    numbervar y := 0;
    numbervar i := 0;
    stringvar final := "";
    You may then hide the 1st and the last formula (Right-click > Format field > Common tab > Suppress)
    Let me know how this goes!
    -Abhilash

  • Average & SUM in a Single criteria in the Pivot View

    Hi,
    Can you plese let me know whether it is possible to have SUM at the Grand Total level & Average on the Right Hand side of the Pivot Table view at the same time.
    Thanks & Regards
    Siva.

    Hi,
    The way you want to do it is not possible.
    What you can do is make a union of 2 reports one is using the Sum and the other the AVG and not use the Grand total provided by OBIEE.It's kind of creating your own Grand Totals
    Look at this thread it will help:
    http://obiee101.blogspot.com/2010/08/obiee-combine-with-similar-request.html
    If you are using pivot table you can think about a new calculate item as a GT
    http://varanasisaichand.blogspot.com/2010/12/aggregate-functions-on-grand-total.html
    Best regards
    Adil
    PS: Please don't forget to close the thread and assign points when your question is answered
    Edited by: adil.harrab on Jun 6, 2011 1:36 PM

  • SSRS 2008 R2 Report - Sum Totals of a Filtered Group

    I'm at a loss here, so any help will me much appreciated. I will do my best to explain, but if you need additional information, please let me know:
    I have a very large dataset of patient data. Specifically for the numbers I need, I have a patient number field, a county field, a 1 or 0 for LastYear field, and a 1 or 0 for CurrentYear field.
    Example:
    PtNo    County  PY  CY
    45676  Scott     0    1
    45322  Cape     1     0
    47686  North     0     1
    The thing I am shooting for on my report is, "Volume growth in 3 counties (+20 cases)."
    I created a group and grouped by County (group name County) and I included a group filter to only include "total cases of CY" are greater than "total cases of PY" to narrow my data to only counties that had a higher current year sum
    than previous year sum.
    Example:
    County  PY    CY  Difference
    Scott    141  143     2
    Cape     90    98      8
    North    78     88    10 
    All is working well, except I don't need to see the Counties themselves, I just need the 3 counties and a difference of 20. 
    I explored online and found tutorials that said to right click on the field and select "Add Total" but this total did not have my filter in it and gave me everyone. I also tried adding a row outside the group and used the RunningValue function
    (i.e. RunningValue(Fields!FYTD_Current_Year.Value, Sum, "County"))  but it gave me a message that states "The Value expression for the text box 'Textbox456' has a scope parameter that is not valid for an aggregate function. The scope
    parameter must be set to a string constant that is equal to either the name of a containing data region or the name of a dataset."
    When I move the row with the RunningValue function inside the group, it runs but I get the same information repeated twice for each county with no final total.
    So I am not sure how to go about getting my values I need for my report. Anybody know how to resolve this?
    Thanks,
    Cyndi
    cpemtp1

    Hi Cyndi,
    Based on my understanding, you specify a filter condition in group properties. Then you want to sum the filtered values for each field.
    In this scenario, we need to specify a filter condition on group level. If we use sum() function out of group, the expression will calculate the total values on dataset level instead of group level. So we can’t simply use expression to achieve this goal.
    However, we can use custom code to record the filtered values for each field, then we can calculate the total based on these values. Please refer to the steps and screenshots below:
    1. Add the custom code below into the report:
    Public Shared Value1 as Integer=0
    Public Shared Function GetValue1(Item as Integer) as Integer
    value1= value1 + Item
    return Item
    End Function
    Public Shared Function GetTotal1()
    return value1
    End Function
    Public Shared Value2 as Integer=0
    Public Shared Function GetValue2(Item as Integer) as Integer
    value2= value2 + Item
    return Item
    End Function
    Public Shared Function GetTotal2()
    return value2
    End Function
    2. Design the tablix like below:
    3. The result looks like below:
    If you have any question, please feel free to ask.
    Best regards,
    Qiuyun Yu

  • SSRS Using Sum and = in a conditional operator

    Hi,
    Still getting to grips with SSRS so any help would be appreciated.
    My aim is to calculate a conditional field using the SSRS expression feature, the datasource is a shared dataset which i can't alter so i can't just go an alter the SQL query or anything.
    In SQL my query would be like this: SELECT COUNT(TotalHours) FROM TableName WHERE TotalHours <= 24
    Is there anyway to combined the Iff and Sum operator's to get a result like the above?
    At present all i managed to come up with is the below but obviously it's not returning the correct amount.
    =IIf(Fields!TotalHours.Value <= "24", Sum(Fields!TotalHours.Value), 0 )
    Please help!
    Edit: Please note that i'm not trying to sum a field based on a condition that relates to another column, i just need a sum of 'TotalHours' that are less than or equal to 24, please also note there is another field called category, each category needs a
    sum of the above.
    Regards,
    Marcus
    Plain_Clueless

    Hi Marcus,
    According to your description, you want to count [TotalHours] when the value of this field is less than 24, right?
    In your scenario, you could use the expression like below:
    =Sum(IIF(Fields!TotalHours.Value<=24,1,0))
    Please note don’t put this expression in the detail rows, you could refer to our test results:
    If you have any question, please feel free to ask.
    Best regards,
    Qiuyun Yu
    Qiuyun Yu
    TechNet Community Support

Maybe you are looking for

  • General questions in abap programming

    hi i have some questions in abap. They are as follows. 1) What you like in SAP and what you don't like?(Interview question) 2) In LSMW please explain about 6th step, maintain fixed values, translations, user defined subroutines? 3) how to create view

  • Artntek-help-urgent

    hi i need explanation of your code and also how you will fix this one.... i saw in ur forum threads..... tabbedpane.setUI(new javax.swing.plaf.basic.BasicTabbedPaneUI() { public Insets getContentBorderInsets(int tabPlacement) { return new Insets(0,0,

  • LabView gives "Invalid Declaration" errors

    Hello there, I am trying to compile a "stm32f10x" project using old generic template project found on the forums (for example, here) and I have gotten around some errors. however I am experiencing an error when compiling which says: C:\Program Files\

  • Why is everything showing in negative color.

    I haven't dropped my iPad or done anything else that would damage it.  I just opened it and all of a sudden the colors were completely off.  It's like it's a negative.  What did I touch or is it broken?

  • What files are affected by a bad block?

    I have a hard drive that appears to be failing.  A sequential block by block read (dd if=/dev/disk0s2 of=/dev/null bs=512) is returning an I/O error on a given block.  I'm going to retire this drive and restore from an earlier backup but I'd like to