Calculating total discount at the row level

Hi,
I want to determine the total discount amount for all of the invoice row levels by summing the row totals that have the same discount % and then multiplying that total by the row discount percent.
Example:
Lets say there is an invoice with 3 line items
Qty     ItemCode     Price    Discount%
2         A                $30            10
2         B                $20            10
2         C                $15             5
I want to figure the total for the first 2 lines (because they have the same discount amount) by multiplying the quantity (230)+(220)=100 and then calculating the discount from this total. (100) * (.10) = $10 and then calculating the discount for the third line item ((215).05)=1.5. This brings the total discount amount to $11.50.
Below is what I have drafted for a query so far.
Select
//For each grouping of items with the same discount %
(SUM ((T0.Quantity * T0.PriceBefDi)) * DiscPrcnt)
FROM INV1 T0 WHERE T0.DocEntry=$[OINV.DocEntry]
Any ideas?
Thanks,
Luke

Gordon,
I was thinking that I would have to use a group by (grouping on the discount %) statement or possible a sub-query to accomplish this. The group by statement would replace the commented section. "//For each grouping of items with the same discount %"
I will work on this query some more and post my results if I figure out a way to accomplish this.
Thanks,
Luke

Similar Messages

  • How to disable (or) Hide the UDF Field in the Row level through Query

    Hi suda,
    thanks for your reply. i also want to know the formatted search query for the UDF present in the row level, i want to hide that also.so pls msg me the query.
    i have written as N$[item.column.row] but it is not working,so keep me posted if your query that works well.
    Regards
    Magesh.

    Magesh,
    I just saw your other messages...
    Go to Tools > User defined fields > Manage User Fields   --  Under Marketing Documents > Rows  check the field name here.
    Then go the Form itself and Click on Form Settings Icon or Click CTRLSHIFTS or Tools > Form Settings and from the Table format Tab make your changes..
    Good luck
    Suda

  • How to avoid seeing data for a particular member in the row level

    Hello,<BR>I am using Essbase. In that i am having members like taks n/a, demand n/a. Purpose of these members are, if i load data for demand, task wont have data so i am mapping to task n/a.And same for the task loading.I am using alphablox for reporting and report script for retriving the data.So, if i select the task n/a and demand n/a then some value will be existing for this. Is there any possibility to remove this from report.I mean while seeing in the report, it should not get this member and respective value for display and also avoid taking this data for any manipulation.I know RESTRICT for column level data. Is there anything for row level restrictions.<BR>Please help me on this.<BR>Regards<BR>R.Prasanna

    Hi,
    Into the rule containing the Color metadata, you can restrict the values of the list.
    In "Has restricted list and pane", list the values 1, 2 and 3 (new line for each value) :
    1
    2
    3
    Romain.

  • How to check the row level security in TOAD for oracle

    Hi ,
    for ex, i have 2 types of users
    normal user and super user
    super user can see the group set (some column name) created by normal user
    but normal user can not see the set created by super user
    this set crestion aslso has 3 types "U','P',S'
    P & S can be viewed by even normal user
    but U should not
    so here we are having some row level security for the normal user .....
    So, in TOAD for oracle how to check that......
    Let me know if i'm not clear

    Like
    I'm the super user....
    And some records are inserted to a table by different users ('a' , 'b', etc....)
    So,if user 'a' logins then he can be able to see only the records inserted by 'a' only...
    how to see in TOAD where such type of scripts (filter conditions) are written.....

  • How to update UDF based upon the row level dimensions.

    Hello Experts,
    I have made 4 new udf at Sales Order.  Its displaying at Righthand side under General Category.
    Now at row level im entering item detail, and other things with 4 profit center vaues.
    So i want that if i enter value in those 4 proft center in row level then it should automatically update those 4 udf with that value.
    It always happen in Add mode of SO, if SO open in update mode then i can update those udf with other values also, which can be differ then row level profit center values.
    If we need to create any trigger or any query for that, then guide me for that.
    Regards,

    Hi Chintesh,
    You can use the option of changing value when the exising column value changes. (also check the option refersh only option)
    pls revert in case more help.
    Regards,
    Datta Kharat

  • Can a target value for KPI calculation be loaded at the Result level in SSM

    Hello
    we are working on a POC where we are loading data at the input level of a dimension for a measure. that measure is averaged up to the result level passing through 1 output level.
    Now my problem is that we can load the target data using Entry and Approval at the same level as we load the actual data i.e at the input level. But our requirement is that the client needs to load the target values at the result level but not at the input level.. how can this be done ?
    Vijay
    Edited by: vijay kumar on Mar 20, 2009 7:20 AM

    Hi Vijay,
    If you are using the BICA to define your KPIs, you can create there Actual and Target Measures with different Dimension Consolidation options. In order to be able to also load data at the output or result level, you can choose from the dropdown the option "ENTER" as the Dimension Consolidation option for the target measure you are creating.
    But if you are using the Cube Builder to create your KPIs, then unfortunately it isn't possible to define different Dimension Consolidation options for the Actual and Target measures of one KPI. In this case, and in the case you are creating your measures directly in PAS, you have to edit the CONSOLINFO document in the PAS model in order to allow for the entering of data in E&A at the output/result level.
    You can set this option by locating your measure in that document and replacing the string "INPUT", at the end of that line, with "ALL". If no line exists yet for your measure (which will happen if you created the measure directly in PAS), then you will need to add it, as in the following example:
    EXAMPLE_MEASURE_ACT,consvar_pmdb.pro,INPUT
    ...in case the actual measure should be consolidated as SUM
    EXAMPLE_MEASURE_ACT,calcavg_pmdb.pro,INPUT
    ...in case the actual measure should be consolidated as AVERAGE
    EXAMPLE_MEASURE_TAR,NONE,ALL
    ...in order not to consolidate the target measure and allow E&A to plan on all levels of its dimensions
    Hope this helps!
    Best regards,
    Ricardo

  • Use first row of table to determine calculation of rest of the rows of that table.

    I have time sheet table where the rows are employees names and the column is the dates in the calender
    Name
    01
    02
    03
    04
    05
    06
    07
    08
    09
    Emp 1
    8
    8
    8
    8
    8
    0
    0
    8
    8
    Emp 2
    8
    7
    8
    9
    8
    0
    0
    8
    7
    Emp 3
    6
    8
    8
    8
    8
    0
    0
    8
    8
    I want to come up with this table - where '1' indicates the public holiday.
    Name
    01
    02
    03
    04
    05
    06
    07
    08
    09
    1
    Emp 1
    8
    8
    8
    16
    8
    0
    0
    8
    8
    Emp 2
    8
    7
    8
    18
    8
    0
    0
    8
    7
    Emp 3
    6
    8
    8
    16
    8
    0
    0
    8
    8
    ** I have the public Holiday table with dates of public holidays. I can do UNION ALL with sheet table and Public Holiday table to get the first row. i.e. if there is a Public Holiday within that date range then it will have '1' in the corresponding field
    of the first row.
    ** Now If the there is a '1' in a field of the first row, I want all values below it to be doubled as shown in the example.
    Please point me in the right direction.
    Marsh Narewec

    create table test (Name varchar(20),[01] int,[02] int,[03] int,[04] int,[05] int,[06] int,[07] int,[08] int,[09] int)
    insert into test values('Emp 1',8,8,8,8,8,0,0,8,8),('Emp 2',8,7,8,9,8,0,0,8,7),('Emp 3',6,8,8,8,8,0,0,8,8)
    ;with mycte as(
    select name, val,col from (select * from test) src
    cross apply (values([01],'01'),([02],'02'),([03],'03'),([04],'04'),([05],'05'),([06],'06'),([07],'07'),([08],'08'),([09],'09')) d(val,col)
    Select name,[01],[02],[03],[04],[05],[06],[07],[08],[09] from
    (select name, Case when col='04' then val*2 else val end val,col from mycte) src
    PIVOT (max(val) For col In ([01],[02],[03],[04],[05],[06],[07],[08],[09])) pvt
    drop table test

  • Sum() function not working properly. Instead of summing, its showing total count of the rows

    We have migrated one application from .net framework 1.0 to .net framework  2 (from Visual studio 2003 to Visual STUDIO 2005). Now after migration we are facing some problem related to the sum function in Crystal report 10. It is not working properly.
    So we migrated to Crystal report XI release 2 (though still using evaluation version for testing purpose), the problem is not yet resolved.
    The problem we are facing is while using the summary in the group field, it is showing the number of rows instead of the sum of the values.
    We have checked the same with min-max functions, and it is working properly with those.
    We have tried to make the sum by formula field. In such case, it is not showing any syntactical error but at execution time, it is throwing an error saying "A number field or currency amount field is required here".
    In the  the report the datatype of the field on which we are applying the sum function, is number, and in the table from where the data is fetched, the datatype is numeric(9,6).
    Any idea why sum function is not working ?
    I was browsing the net and saw running totals can be a work around for such summation issues in Crystal Report XI.
    Can you please provide insight of how to implement running totals for summation purpose in solving such issues.

    Hi,
    Running totals are more accurate than Summary Totals in Crystal.  Why? ...ask Crystal.  Anyway, just right click on Running Totals, create a new one, and enter you fields, etc. For group totals, it gives you a place to reset the totals for each group, etc.  Pretty self explainatory. 
    Jim

  • Is there a way  we can control Display access in SE16 at the row level?

    Table MARC has material master data at plant level,i want a user to be able to view only plant A via SE16.SAP has  objects to control access in MM03 but how can we control view access in SE16 without totally eliminating the table access.
    If not are there any alternatives?Like develop ZSE16 or create a new DB view etc?Appreciate your reply

    This link has some info where OB52 is restricted by company code - the principles may apply to your application though you will need to create a transaction for it
    http://www.sap-img.com/zf011.htm
    it also won't be any use if the user has SE16 or similar - though you don't give these if you want to restrict at any level lower than groups of table
    hope that helps
    cheers
    alex

  • Can you set fields as requied at the row level in a table?

    I have a table that is used to add data (rows). Can certain fields be set to required base on other values in that row?

    It is not clear from the developers guide exactly how to accomplish this. When I follow the example given all rows are still impacted by a change. This is probably because the PVO has only one record in it and not a record for each row. Is that correct?

  • Flash Quiz not calculating totals correctly at the end

    Hi,
    I am working on a Flash XML quiz, that can be found on this
    tutorial
    http://www.permadi.com/tutorial/flashMXQuiz/index3.html
    I have it just about working except at the end on the summary
    screen, the application is supposed to calculate the number right,
    the number wrong and the percentage.
    I am not sure what I have missed, but I zipped up the .fla
    file and the xml file and wanted to see if someone could take a
    look. I know the problem isn't with the XML file so it must be in
    the AS towards the end in the summary screen section.
    here is the path the download the zip
    http://www.inspired-evolution.com/Quiz.zip

    the XML file is only storing the questions. For the scoring
    calculations I am using three dynamic text boxes with var values of
    numOfQuestionsAnsweredCorrectly,numOfQuestionsAnsweredCorrectly,
    numOfQuestionsAnsweredIncorrectly
    and in the AS I am using
    userScore=(numOfQuestionsAnsweredCorrectly*100)/
    (numOfQuestionsAnsweredIncorrectly+numOfQuestionsAnsweredCorrectly)
    I am following the tutorial to a Tee, so unless there is a
    typo or errors w/ the tutorial this should be working.

  • How to find out the difference between the row level data in 2 dump files.

    Hi,
    I have got the export dump files from 2 different databases(for which I dont have access).
    They have got the same tables and same number of rows.
    how to compare the data within the tables(in the dump files).
    Cheers,
    Kunwar

    user9131570 wrote:
    Hi,
    I have got the export dump files from 2 different databases(for which I dont have access).
    They have got the same tables and same number of rows.
    how to compare the data within the tables(in the dump files).
    Cheers,
    KunwarWhy you want to do it? What's the business need? Without importing, its not possible to read the dump file * .
    Aman....
    * If you are using Data pump, you can make a sql file and can see the components of the dump file.

  • Discount at the time if Payment for Segmented COA

    Dear Experts ,
    In my system , we are using the segmented COA in Indian Localization.
    So at the Payment , when we provide the Cash Discount at the ROW Level after selecting the Bills.
    The System Passes the JE with Same Account for Discount in Both the Segment Entry .
    Need to separate the Discount Account as per the segments.
    Please suggest .
    Thanks
    Gangadhar

    Hi Gangadhar ,
    According to me it is due to the determination done for Sales And Purchase Tab .
    Where you have to Enter a Account for CASH Discount.
    So at that part we can only Put Single Account,  it will of any of the segments.
    So no matter for which Segment you are doing the Payment , The discount will go to that account Only.
    Thanks
    Ashish

  • Row level Tax Calculation

    Hi,
    I have to calculate the row level tax in following query.
    SELECT T0.[DocEntry], T0.[DocNum], T0.[DocDate], T0.[CardCode], T0.[CardName], T0.[NumAtCard], T1.[LineNum], T1.[ItemCode], T1.[Dscription], T1.[Quantity], T1.[LineTotal], T1.[VatSum], T1.[GTotal], T1.[TaxCode],
    (SELECT Sum(TaxSum) FROM INV4 where statype=-90 and stacode='BED10' and DocEntry=T1.DocEntry) as ' ED 10% (Rs.) ',
    (SELECT Sum(TaxSum) FROM INV4 where statype=-60 and DocEntry=T1.DocEntry) as 'Cess 2% (Rs.)',
    (SELECT Sum(TaxSum) FROM INV4 where statype=-55 and DocEntry=T1.DocEntry) as 'HSCess 1% (Rs.)',
    (SELECT Sum(TaxSum) FROM INV4 where statype=4 and stacode='CST2' and DocEntry=T1.DocEntry) as ' CST 2% (Rs.) '
    FROM OINV T0  LEFT JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry LEFT JOIN INV4 T2 ON T0.DocEntry = T2.DocEntry AND T1.LineNum = T2.LineNum WHERE T0.[DocEntry] >=[%0] AND  T0.[DocEntry] <=[%1] AND T0.DocType='I'
    GROUP BY T0.[DocEntry], T0.[DocNum], T0.[DocDate], T0.[CardCode], T0.[CardName], T0.[NumAtCard], T1.[LineNum], T1.[ItemCode], T1.[Dscription], T1.[Quantity], T1.[LineTotal], T1.[VatSum], T1.[GTotal], T1.[TaxCode], T1.[DocEntry]
    ORDER BY T0.[DocEntry], T0.[DocNum], T0.[DocDate], T1.[LineNum]
    Regards,
    Datta Kharat

    Hi Datta........
    Try this......
    SELECT M.DocEntry, M.DocNum AS 'AR Inv. #', M.DocDate as 'Date', L.ItemCode, L.Dscription, L.Quantity, L.TaxCode, M.CardName as 'Customer Name',M.NumAtCard as 'PO No. & Dt.',
    L.LineTotal as 'Base Amt.(Rs.)',
    (SELECT Sum(TaxSum) FROM INV4 where statype=-90 and stacode='BED10' and DocEntry=M.DocEntry And LineNum=M.LineNum) as ' ED 10% (Rs.) ',
    (SELECT Sum(TaxSum) FROM INV4 where statype=-90 and stacode='BED4' and DocEntry=M.DocEntry And LineNum=M.LineNum) as ' ED 14% (Rs.) ',
    (SELECT Sum(TaxSum) FROM INV4 where statype=-60 and DocEntry=M.DocEntry And LineNum=M.LineNum) as 'Cess 2% (Rs.)',
    (SELECT Sum(TaxSum) FROM INV4 where statype=-55 and DocEntry=M.DocEntry And LineNum=M.LineNum) as 'HSCess 1% (Rs.)',
    (SELECT Sum(TaxSum) FROM INV4 where statype=1 and stacode='VAT4' and DocEntry=M.DocEntry And LineNum=M.LineNum) as ' VAT 4% (Rs.) ',
    (SELECT Sum(TaxSum) FROM INV4 where statype=1 and stacode='VAT5' and DocEntry=M.DocEntry And LineNum=M.LineNum) as ' VAT 5% (Rs.) ',
    (SELECT Sum(TaxSum) FROM INV4 where statype=1 and stacode='VAT12.5' and DocEntry=M.DocEntry And LineNum=M.LineNum) as ' VAT 12.5% (Rs.) ',
    (SELECT Sum(TaxSum) FROM INV4 where statype=4 and stacode='CST2' and DocEntry=M.DocEntry And LineNum=M.LineNum) as ' CST 2% (Rs.) ',
    (SELECT Sum(TaxSum) FROM INV4 where statype=4 and stacode='CST4' and DocEntry=M.DocEntry And LineNum=M.LineNum) as ' CST 4% (Rs.) ',
    (SELECT Sum(TaxSum) FROM INV4 where statype=4 and stacode='CST5' and DocEntry=M.DocEntry And LineNum=M.LineNum) as ' CST 5% (Rs.) ',
    (SELECT Sum(TaxSum) FROM INV4 where statype=4 and stacode='CST12.5' and DocEntry=M.DocEntry And LineNum=M.LineNum) as ' CST 12.5% (Rs.) ',
    (SELECT Sum(TaxSum) FROM INV4 where statype=5 and stacode='ST10' and DocEntry=M.DocEntry And LineNum=M.LineNum) as ' ST 10% (Rs.) ',
    (SELECT Sum(TaxSum) FROM INV4 where statype=6 and stacode='Cess_ST2' and DocEntry=M.DocEntry And LineNum=M.LineNum) as ' Cess_ST 12.5% (Rs.) ',
    (SELECT Sum(TaxSum) FROM INV4 where statype=-10 and stacode='HSC_ST1' and DocEntry=M.DocEntry And LineNum=M.LineNum) as ' HCS_ST 12.5% (Rs.) ',
    (Select Sum(LineTotal) From INV3 Q Where Q.DocEntry=M.DocEntry) AS 'Freight (Rs.)',
    M.DocTotal as 'Total (Rs.)',U.Dscription, U.ChapterID
    FROM OINV M LEFT OUTER JOIN INV1 L on L.DocEntry=M.DocEntry
    LEFT OUTER JOIN INV4 T on T.DocEntry=L.DocEntry and L.LineNum=T.LineNum
    LEFT OUTER JOIN INV5 J ON M.DocEntry = J.AbsEntry
    LEFT OUTER JOIN INV3 Q ON M.DocEntry = Q.DocEntry
    LEFT OUTER JOIN OITM S ON L.ItemCode = S.ItemCode
    LEFT OUTER JOIN OCHP U ON S.ChapterID = U.AbsEntry
    WHERE (M.DocDate >= '[%0]' AND M.DocDate <= '[%1]') AND M.DocType='I'
    GROUP BY
    M.DocNum,M.DocDate,L.ItemCode, L.Dscription, L.Quantity, L.TaxCode, M.CardName,M.NumAtCard,L.LineTotal,M.DocEntry,M.DiscSum,M.WTSum,M.DocTotal,U.Dscription, U.ChapterID
    ORDER BY
    M.DocNum,M.DocDate,L.ItemCode, L.Dscription, L.Quantity, L.TaxCode, M.CardName,M.NumAtCard,L.LineTotal,M.DocEntry,M.DiscSum,M.WTSum,M.DocTotal,U.Dscription, U.ChapterID
    Regards,
    Rahul

  • Row level calculation

    hi SAP kings
    I created one udf in row level.its contain the different data in each row.i create the another one filed in title part the title part have a value of division of row level value.how can i write the query for this ticket

    Hello Lakshmi Narayanan,
    When you are on the module, the row level values of one row cannot be accessed in another.
    Example: If you want row 1 UDF value divided by row 2 UDF value, it will not be possible.
    I also believe you want to copy the result to the header level UDF and again from within the module this would not be possible.
    There is the option of using the SBO_SP_TransactionNotification stored procedure to make the calculation and update UDF's.
    Let me know
    Suda

Maybe you are looking for