Year-To-Date Sales by month calculation in cube

Hi everyone,
I want to already calculate the 'YTD Sales'by month in my cube, so I increase performance when the user is running his report. YTDSALES = Actual Month Total Sales + Previous month YD Total Sales.
Not sure how to implement it in the update rule. Looks like a lt of coding. Any suggestions would be greatly appreciated.
Thanks, RL

You should do a little loop in the start routine and write all the monthly values into any periods up to period 12. The coding could look like:
data: l_d_data_package like line of data_package,
      l_t_data_package TYPE STANDARD TABLE OF 
                       DATA_PACKAGE_STRUCTURE
                       WITH HEADER LINE
       WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 0.
  loop at data_package into l_d_data_package.
    l_d_data_package-/bic/ytdsales =
         l_d_data_package-/bic/sales. "or other keyfig
    while l_d_data_package-calmonth+4(2) <= '12'.
      append l_d_data_package to l_t_data_package.
      clear l_d_data_package-/bic/sales. "or other keyfig
      l_d_data_package-calmonth+4(2) =
         l_d_data_package-calmonth+4(2) + 1.
*     If you have fiscper or fiscper3 or
*     calquarter you may need to adjust it here too.
    endwhile.
  endloop.
  data_package[] = l_t_data_package[].
But you should first check if aggregates or precalculated web templates are better.
Best regards
   Dirk

Similar Messages

  • Year to date sales

    I'm trying to calculate year to date sales value. If I have more than one packet size my values do not match expected results. Is there a way I can have all data in single packet in start routine or end routine. I don't want to make cahnge to setting in DTP. My initial package should pick all values.
    For example:
    Comp Month Sales
    A        1         1
    A        2         2
    A        3         3
    A        4         4
    A        5         5
    A        6         6
    A        7         7
    A        8         8
    My expected result should be:
    A        1         1
    A        2         1 + 2 = 3
    A        3         3 + 3 = 6
    A        4         6 + 4 = 10
    A        5         10 + 5 = 15
    A        6         15 + 6 = 21
    A        7         21 + 7 = 28
    A        8         28 + 8 = 36
    If I have two packets ( size 4each) then my calculation doesn't match the expected results
    A        1         1
    A        2         1 + 2 = 3
    A        3         3 + 3 = 6
    A        4         6 + 4 = 10
    A        5          5
    A        6         5 + 6 = 11
    A        7         11 + 7 = 18
    A        8         18 + 8 = 26
    Can any one hlep me to resolve this issue.

    Hi,
    The best way is....
    Create a report and calculate it in Report like below.
    Create a Customer Exit Variable called FMYEAR on 0CALMONTH and then write code like below.
    DATA :  l_s_range TYPE rsr_s_rangesid,
                loc_var_range LIKE rrrangeexit,
                zbdatj LIKE t009b-bdatj,
               zbuper LIKE t009b-poper,
    First Month Of Current Fiscal year comment*
        WHEN 'FMYEAR'.
          CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
                 EXPORTING
                   i_date               = sy-datum
            I_MONMIT             = 00
                   i_periv              = 'V3'
                IMPORTING
                  e_buper              =  zbuper
                  e_gjahr              =  zbdatj.
          CLEAR: l_s_range.
          l_s_range-low+4(2) = '04'.
          l_s_range-low+0(4) = zbdatj.
          l_s_range-sign = 'I'.
          l_s_range-opt = 'EQ'.
          APPEND l_s_range TO e_t_range.
    and then create a restricted Kefigure with 0CALMONTH and value, and restrict calmonth with FMYEAR;0CALMONTH (there are variables and the values are  in between FMYEAR;0CALMONTH)
    Thanks
    Reddy

  • YTD(year to date) Sales [List Price/ Gross Sales ]

    How to create YTD(year to date) Sales [List Price/ Gross Sales ] depending on the selection in filter

    Do you have the measure names as list of values in prompt?
    Rgds,
    Dpka

  • Year to Date Problem on Monthly Loads

    Hi SDN team,
    I have few clarifications necessary.
    I've a query & it uses 2 structures. we decide to use cells using cell editor afterwards.
    We have plan versus actual issue. One row is plan for one full year. We have a plan figure for each month of year 2004, from Jan till Dec. Now I need to create a totals. Is it possible to create total column for this?
    In that column the plan figures ahould be shown as sum for the "year to date-values" - for example from Jan'04 till Apr'04 or Jun'04, not the totals for the whole year.
    Selected Month SEP. Plan from Jan - Dec. Totals: 2*Total. Total we  need: Sum (year to date because of month). If there's any solution for this please let me know.

    Hi, You need to add the YTD logic/functions between the 2 statements... Please try this... I've added the crude logic here. Pls. refine as you need for your requirement.
    WHEN 'VAR4JUN'.
        IF I_STEP = '2'.
          LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
                      WHERE VNAM = 'ZYOUR_VARIABLE'.
    ** DATA INITIALIZATION **  (This is optional)
            TV4Y = LOC_VAR_RANGE-LOW+0(4). ** YEAR
            TV4M = LOC_VAR_RANGE-LOW+4(2). ** MONTH
    ** FUNCTION **
            CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
              EXPORTING     INPUT  = TV4M
              IMPORTING       OUTPUT = TV4M.
    ** DATA LOGIC FOR YTD**
            IF TV4M= '06' OR TV4M= '07' OR TV4M= '08' OR
                TV4M= '09' OR TV4M= '10' OR TV4M= '11' OR TV4M= '12'.
                      CONCATENATE TV4Y '06' INTO L_S_RANGE-LOW. ** Also for HIGH
            ELSEIF TV4M= '01' OR TV4M= '02' OR TV4M= '03'.              
                      TV4Y = TV4Y - 1.
              CONCATENATE TV4Y '06' INTO L_S_RANGE-LOW.. ** Also for HIGH
            ENDIF.
                    L_S_RANGE-SIGN = 'I'.
                    L_S_RANGE-OPT = 'EQ'.
            APPEND L_S_RANGE TO E_T_RANGE.
          ENDLOOP.
        ENDIF.

  • Year to Date Value to be Calculated from Month Numbers

    We have an IP Application running.  We are using a copy of the standard ECCS Transaction Data Cube to do the Planning by Consolidation Item (Profit & Loss and Balance Sheet).
    We have two key figures - Month Value and YTD Value.
    On the planning layout when the user enters the for the month value we need the key figure for the month to be updated as well as the YTD value to be updated based on the entries in the for the month key figure from Jan of the year to the month of entry.
    Is this possible either on the layout or through a FOX function.
    Thanks a lot for your help in advance.

    Would you be able to share some sample code if you have any?
    Thanks

  • Query to show BP year to date sales minus credits

    Hi Experts,
    I would like a query which will show me a single line for each BP:
    BP Code,  Salesperson,  BP Name, Sales Group, Sales YTD (ex vat)
    I want the Sales YTD to be be calculated as total invoiced sales less any credits,  
    Thanks in advance for any help..
    regards
    Geoff

    Hi,
    Check this if it helps :
    select t0.cardcode as 'Business Partner Code' ,t2.slpname as 'Sales Person Name',
    t0.cardname as 'Business Partner Name', t0.GroupCode as 'Sales Group',
    sum(t3.doctotal)- sum(t3.vatsum) as 'YTD Sales',
    sum(t4.doctotal) - sum(t4.vatsum) as 'YTD Credit Memo',
    sum(t5.doctotal) as 'YTD Payments'
    from OCRD t0
    inner join JDT1 t1 on t0.cardcode = t1.shortname
    inner join OSLP t2 on t0.slpcode = t2.slpcode
    left join OINV t3 on t3.objtype = t1.transtype and t3.docdate >= '2011.01.01' and t3.docdate <= '2011.12.31'
    left join ORIN t4 on t4.objtype = t1.transtype and t0.slpcode = t4.slpcode and t4.docdate >= '2011.01.01' and t4.docdate <= '2011.12.31'
    left join ORCT t5 on t5.transid = T1.transid and t5.docdate >= '2011.01.01' and t5.docdate <= '2011.12.31'
    where
    cardtype = 'C' and t1.refdate >= '2011.01.01' and t1.refdate <= '2011.12.31'
    group by t0.cardcode, t2.slpname,t0.cardname,t0.groupcode
    order by t0.cardcode
    Kind Regards,
    Jitin
    SAP Business One Forum Team

  • SSRS Date parameter - current month from SSAS cube

    I have a SSAS cube with a date dimension called Posting Period and now I would like to have my report parameter using this date dimension to show the current month.
    So far I have worked out the following expression which are working(Fiscal year calendar going from May to May) for the year component - but I can't figure out how to get it to work on Quarter date part (and the month) so as you can see
    the Quarter and month is hardcoded in the below expression:
    ="[PostingPeriod].[Posting Period].[Year].&[" + CStr(Year(Today())-1) + "].&[Q4].&[10]”
    Any help would be appriciated.
    Tx

    Hi HCMJ,
    In your scenario, you use the expression
    ="[PostingPeriod].[Posting Period].[Year].&[" + CStr(Year(Today())-1) + "].&[Q4].&[10]”
    to set the default value of the parameter and then use it in the MDX query, right?
    If in this case, you can use the expression below
    ="[PostingPeriod].[Posting Period].[Year].&[2013].&[Q" & DatePart(DateInterval.Quarter,today()) & "].&[10]”
    to set the value on Quarter date part.
    And it returns:
    If I have anything misunderstood, please point it out and elaborate the meaning of "but I can't figure out how to get it to work on Quarter date part (and the month) so as you can see the Quarter and month is hardcoded
    ", so that we can make further analysis.
    Regards,
    Charlie Liao
    TechNet Community Support

  • Year to date variable

    Hello experts,
    I have installed the variable : Current Year From Start, Range to Current date(Sap Exit) with tech name 0I_IPMD7. How do i know which time infoObject it is applicable to?
    i want to use this in the year to date sales calculation. But cannot see this available in any of the time infoobjects in the present 0sd_c03 cube!!
    please guide..
    regards,

    Hi Aby,
    Please look at RSZGLOBV table. You'll see that this variable is based on 0IPM_BEGDATE characteristic.
    You can also look in SE37 at the FM RSVAREXIT_0I_IPMD7 to figure out what the code is doing.
    Best regards,
    Eugene

  • Loading year to date data

    Due to sourcing issues, it would be easier to load year to date and calculate month. All documentation shows month rolling up to year to date. Will year to date work?

    You can create your time dimension so that you load your YTD data into a 'YTD' member. You can then use a shared hierarchy to calculate your discrete months.E.g - Jan = "Jan YTD"Feb = "Feb YTD" - "Jan YTD"Mar = "Mar YTD" - "Feb YTD"etc.If Time is dense then these can easily be set to dynamic calcHope this helpsDave Cooper, Analitica Ltdwww.analitica.co.uk

  • Month to Date and Year to date calculation

    Hello Experts,
    It would be great If you could provide the formula to implement in BO universe or in the Reporting level for the below requirement.
    MTD, LastMonth, Year to Date, Last to LastMonth and examples are below.
    Last Week:
    Eg: Monday through Sunday
    Description: Based on Todayu2019s date, select the Monday of the previous week for the start date and Sunday will be the end date.
    Example:
    If Today is May 22, 2009
    The result would be, Monday = May 11, 2009, Sunday = May 17, 2009
    MTD:
    If Today is May 22, 2009
    I need a result MTD = May 1, 2009 u2013 May 21, 2009
    LastMonth:
    If Today is May 22, 2009
    I need a result LastMaont = April 1, 2009 u2013 April 30, 2009
    Last to LastMonth:
    If Today is May 22, 2009
    I need a result LastMaont = March 1, 2009 u2013 March 31, 2009
    Thank you.

    Nisniki,
    Here are the methods using WebI:
    MTD: 
    Create a local variable "MTD Start"
    =RelativeDate(LastDayOfMonth(RelativeDate(CurrentDate();-30));1)
    Create a local variable "MTD End"
    =currentdate()
    LastMonth
    =LastDayOfMonth(RelativeDate(CurrentDate();-30))
    Year to Date
    create a local variable "YTD Begin"
    =ToDate("01/01/"+FormatNumber(Year(CurrentDate());"####");"mm/dd/yyyy")
    (reuse "MTD End" or build a "YTD End" variable same as "MTD End")
    Last to LastMonth
    (similiar to MTD, but using "60" versus "30" to move back two months versus moving back 1 month.
    To perform this stuff in the universe requires an understanding of the SQL syntax for the paricular vendor your are working with.  ANSI SQL agrees to represent and compute dates uniformly, however, the functions to make it happen varies by the vendor.
    Thanks,
    John

  • Year to Date and Monthly totals

    I know that this is rather simplistic, but I'm new to Discoverer and need to set up a bunch of sales reports with MTD and YTD columns. I'm going to be using the same SQL query for many of my reports but customizing the reports to show sales by state, product line, etc.
    Is there a formula/function I can use in Discover for the Month to Date and Year to Date totals?
    Thanks,
    Joseph

    Hi Joseph
    You can use the analytic range SUM calculation for these. For the month to date, use the a PARTITION BY of month with a range of all the preceding rows in the partition up to and including the current row. For the year, you would simply change the PARTITION BY to be the year.
    Here are some examples drawn from my own database:
    I have the following items:
    ORDER_YEAR
    ORDER_MONTH
    ORDER_DATE
    SELLING_PRICE
    With these defined, the formula for month to date is:
    SUM(Sales.Selling Price SUM) OVER (PARTITION BY ORDER_MONTH ORDER BY ORDER_DATE ASC ROWS UNBOUNDED PRECEDING)
    The formlua for year to date is:
    SUM(Selling Price SUM) OVER(PARTITION BY ORDER_YEAR  ORDER BY  ORDER_DATE ASC  ROWS  UNBOUNDED PRECEDING )
    Basically what we are doing is telling Discoverer to SUM the SELLING_PRICE, and you should be able to take these and adjust them for your own report.
    Let me take a look at the month to end and describe what is going on. Basically the PARTITION BY is defining a set of rows which are to be included. In this case it is all rows that have the same ORDER_MONTH. The ORDER BY clause tells Discoverer to place the items in order, with the oldest order first. The ROWS UNBOUNDED PRECEDING tells Discoverer to SUM all of the items within the set (within the PARTITION BY) from the oldest item (UNBOUNDED PRECEDING) to and including the current item. We could have added a BETWEEN clause too but that is implied. With a BETWEEN clause it would look like this:
    SUM(Sales.Selling Price SUM) OVER (PARTITION BY ORDER_MONTH ORDER BY ORDER_DATE ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
    If you want the current row to be included with UNBOUNDED PRECEDING you don't need to explicitly name it because that is the default. Other options you could use are these:
    UNBOUNDED FOLLOWING - this SUMS to the end of the PARTITION
    ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - you can guess that this will add all of the items, which you will rarely use because if you omit the ROWS command then this range between first and last is actually the default
    Rather than ROWS BETWEEN you can also say RANGE BETWEEN, like this:
    SUM(Sales.Selling Price SUM) OVER (PARTITION BY ORDER_MONTH ORDER BY ORDER_DATE ASC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
    I hope this little dissertation on running totals helps.
    Best wishes
    Michael

  • Want the Average of sales for months up to date, with empty months included

    How do I create an MDX that gives me the average of , f.ex., Sales
    Note that some months may not have sales, but the month should still be counted.
    The result I want to get out is a listing of Years with average of Sales for each year. Where current year only calculates up to current month.
    Lets say that todays month is 2014-05 and we have the following figures for this year.
    Month Sales
    2014-01 10
    2014-02 20
    2014-03 Null
    2014-04 15
    2014-05 10
    The calculation should be Sum(Sales) divided by 5 months: 55/5 = 11
    If I use:
    Avg( Descendants([Date].[Calendar].[Month].CurrentMemeber
    , [Date].[Calendar].[Month])
    , [Measures].[Internet Sales]
    It will exclude 2014-03, which is wrong!
    If I use CoalesceEmpty() to fill in the Nulls:
    Avg( Descendants([Date].[Calendar].[Month].CurrentMemeber
    , [Date].[Calendar].[Month])
    , CoalesceEmpty([Measures].[Internet Sales],0)
    It will fill in 0 for all months 2014 (up to 2014-12), which is also wrong!
    It feels like a really simple calculation, but I can't make it work.
    Thanks

    I finally had to fix it by checking the number of months to get it right.
    This solved my problem and gave me the correct averages on year and month level.
    Create Member CurrentCube.[Measures].[COMPLAINT COUNT AVG CALC] As Null
    ,Format_String = ";;;\N\/\A",VISIBLE = 1;
        // For Year level - Show average of year = Sum/NumOfMonth. If this year then up to this month else divide by 12
        SCOPE([COMP CREATION DATE].[YEAR].[YEAR], [Measures].[COMPLAINT COUNT AVG CALC]);
            This = IIF([COMP CREATION DATE].[IS THIS YEAR].&[Y],
                            DIVIDE(SUM([COMPLAINT Count]),  Format(now(), "MM")),
                            DIVIDE(SUM([COMPLAINT Count]),  12)
            Format_String(This)="# ### ##0";
            NON_EMPTY_BEHAVIOR(This) = { [Measures].[COMPLAINT Count] };
        END SCOPE;
        // For month level - Show average of month = Sum/NumOfDaysInMonth
        SCOPE( [COMP CREATION DATE].[Year-Month-Date].[YEAR MONTHNO], [Measures].[COMPLAINT COUNT AVG CALC]);
            This = IIF(not isempty([Measures].[COMPLAINT Count]),
                    Avg(
                        Descendants(
                         [COMP CREATION DATE].[Year-Month-Date].CurrentMember,
                         [COMP CREATION DATE].[Year-Month-Date].[DATE ID]
                        CoalesceEmpty([Measures].[COMPLAINT Count],0)
                        ,Null
            Format_String(This)="# ### ##0";
            NON_EMPTY_BEHAVIOR(This) = { [Measures].[COMPLAINT Count] };
        END SCOPE;
    mStenport

  • Spread Data Over Multiple Months & Years with Data from Multiple Years

    Hello Everyone,
    I have a complex calculation for spreading values over several months spanning mulitle years. Because we have a 36 month rolling Forecast, a more sophisticated calc is required as opposed to hard coding months or years.
    Heres the description:
    Users enter the following data,
    FY11     BegBalance     Number of BOD Members     10
              BOD Options Vesting Months     20
              BOD Options Accounting Value     10
              BOD Options- Number of Shares     100
              BOD Grant Month     Aug
    FY12     BegBalance     Number of BOD Members     5
              BOD Options Vesting Months     10
              BOD Options Accounting Value     5
              BOD Options- Number of Shares     200
              BOD Grant Month     Oct
    FY13     BegBalance     Number of BOD Members     20
              BOD Options Vesting Months     8
              BOD Options Accounting Value     20
              BOD Options- Number of Shares     100
              BOD Grant Month     Feb
    Based on the above;
    "BOD Stock" is calculated as following/month=Number of BOD Members*BOD Options Accounting Value*BOD Options- Number of Shares/ BOD Options Vesting Months
    Start month for the above is based on "BOD Grant Month". So, for instance considering data for FY11:
    The total "BOD Stock" value is $10000 (originating from FY11) with start month of AUG in FY11 and the number of months to spread over is 20 months. So, essentially the "BOD Stock" per month (originating from FY11) is $500 starting from AUG FY11 to Mar FY13.
    Similarly, the total "BOD Stock" value is $5000 (originating from FY12) with start month of OCT in FY12 and the number of months to spread over is 10 months. So, essentially the "BOD Stock" per month (originating from FY12) is $500 starting from OCT FY12 to JUL FY13.
    The challange I am facing is because of the number of months to spread. Because I have data to spread from multiple years and each year's data spills into the following years, each year should accumulate data from prior years. For instance;
    FY11 should include only FY11
    FY12 should include FY11 and FY12
    FY13 should include FY11, FY12 and FY13.
    Could anyone suggest a smarter way to do this without writting code for each year, maybe using @MDALLOCATE function? The following shows how data should be spread and accumulated.
                             BegBalance     Jan     Feb     Mar     Apr     May     Jun     Jul     Aug     Sep     Oct     Nov     Dec     Period
    FY11     Number of BOD Members          10     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi
         BOD Options Vesting Months          20     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi
         BOD Options Accounting Value     10     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi
         BOD Options- Number of Shares     100     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi
         BOD Grant Month               Aug     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi
              BOD Stock               10000     #mi     #mi     #mi     #mi     #mi     #mi     #mi     500     500     500     500     500     #mi
    FY12     Number of BOD Members          5     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi
         BOD Options Vesting Months          10     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi
         BOD Options Accounting Value     5     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi
         BOD Options- Number of Shares     200     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi
         BOD Grant Month               Oct     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi
              BOD Stock               5000     500     500     500     500     500     500     500     500     500     1000     1000     1000     #mi
    FY13     Number of BOD Members          20     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi
         BOD Options Vesting Months          8     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi
         BOD Options Accounting Value     20     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi
         BOD Options- Number of Shares     100     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi
         BOD Grant Month               Feb     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi     #mi
              BOD Stock               40000     1000     6000     6000     5500     5500     5500     5500     5000     5000     #mi     #mi     #mi     #mi
    Appreciate your inputs!
    Edited by: user10678366 on Oct 12, 2010 3:21 PM

    Why not use substitution variables for Years? you could have something like &Year1, &Year2, &Year3
    Cheers

  • Problem with bex query listing sales "this month" and "same month last year

    Hi,
    I've created a query in BW BEx, where I have a mandatory variable for 0calmonth, and I list 0material and sales (in volume, liter). And I have a restricted key figure giving me sales (volume in liter) restricted with 0calmonth = variable - 12, to give me the sale for the same month the user select, previous year.
    This seems to be working, the sum is correct, but when adding up the number for the sales in the month previous year, the numbers does not fit the sum in the end.
    I think the report only lists materials with sales the month selected in the variable, if a material has not been sold that month, but in the same month last year, it's not listed in the reports, but it's added in the sum in the end.
    Example.
    We have three records like this:
    material - calmonth - volume
    101 - 01.2010 - 5
    101 - 01.2011 - 8
    201 - 01.2010 - 7
    The report will give the following (calmonth variable = 01.2011)
    Material - volume this month - volume same month last year
    101 - 8 - 5
    Sum 8 - 12
    Any way to solve this issue? We noticed because we run BO - Webi on top of the BEx query, and BO sum's the values per material, and in webi the report would give us the sum 8 and 5.
    Any input is appreciated.
    Regards,
    Øystein

    Hi,
    thanks for your reply.
    The error is that the report only seems to list materials that has been sold "this month", and if the same material was sold the same month last year, it will also list the volume for this.
    But if the material is only sold in the same month last year, it's not listed in the report, but it's calculated into the sum at the end.
    The report is listing material, which is why the error presents itself, as you said
    Getting 8 minus 12 is correct unless you drill down by material. In that case, it should be 8 minus 5 and 0 minus 7.
    The row with 0 - 7 is not shown, and my guess is that the report will only list materials that has sales this month (which has been selected in the variable)
    Regards,
    Øystein
    Edited by: Oystein Gundersen on Mar 21, 2011 4:36 PM

  • Getting Turnover Year to Date amount in Sales Order

    Hi Experts
    I would like to be able to have a UDF on Sales Order which shows Sales the Turnover Year to Date for the BP.
    I have created a UDF which is formatted as an amount field and a formatted search with the following syntax.  it is essentially a calculation of the total of all invoices minus credit notes:
    (select (select sum(t1.doctotal) - sum(t1.vatsum) from oinv t1 where (t1.cardcode = t0.cardcode) AND ((T1.[docdate]>='01.01.09') AND (T1.[docdate]<=GETDATE())))
    - (select sum(t2.doctotal) - sum(t2.vatsum) from orin t2 where (t2.cardcode = t0.cardcode)  AND ((T2.[docdate]>='01.01.09') AND (T2.[docdate]<=GETDATE()))))
    from OCRD T0  INNER JOIN OINV T1 ON T0.CardCode = T1.CardCode INNER JOIN ORIN T2 ON T0.CardCode = T2.CardCode
    WHERE T0.[CardCode] = $[$4.1.0]
    it is working for me unfortunately and I hope one of the experts can tell me where I am going wrong?
    Thanks
    Jon

    Hi
    Try this,
    DECLARE @a Numeric(19,6)
    DECLARE @b Numeric(19,6)
    Set @a = Select (SUM(T1.DocTotal) - SUM(T1.VATSUM))
    FROM  OCRD T0
    INNER JOIN OINV T1 ON T0.CardCode = T1.CardCode
    WHERE T0.CardCode = $[$4.0.0]
    AND
    T1.DocDate '01/01/2009' AND T1.DocDate<= 'GETDATE()'
    Set @B = Select SUM(T2.DocTotal) - SUM(T2.VATSUM)
    FROM OCRD T0
    INNER JOIN OINV T1 ON T0.CardCode = T1.CardCode
    INNER JOIN ORIN T2 ON T0.CardCode = T2.CardCode
    WHERE T0.CardCode = $[$4.0.0]
    AND
    T2.DocDate>= '01/01/2009' AND T2.DocDate<= 'GETDATE()'
    SELECT (@a-@b)
    Regards,
    Madhan.

Maybe you are looking for