Last year sales calculation in calculated column

Hi everybody!
Please help me to solve issue with last year sales calculation in calculated column. I have 'Fact' table with sales for every period in it and related table 'Time' with 1, 2, 3 'PeriodID' column for string MAT 2011, MAT 2012, MAT 2013.
I know the solution for measure:
=CALCULATE ( SUM(Fact[Sales]); FILTER (ALL ('Time'); 'Time'[PeriodID] = MAX(Time[PeriodID]) - 1))
But for the purpose of my analysis I need to make a calculated column. What I want to see looks like this table:
Product
Period
Sales
SalesLY
A
MAT 2013
17
10
B
MAT 2013
20
23
C
MAT 2013
45
33
D
MAT 2013
13
16
A
MAT 2012
10
8
B
MAT 2012
23
31
C
MAT 2012
33
5
D
MAT 2012
16
22
A
MAT 2011
8
0
B
MAT 2011
31
0
C
MAT 2011
5
0
D
MAT 2011
22
0

Thanks for the idea!
It's an option. I slightly modified expression to make it more generic:
=CALCULATE
      SUM (Fact[Sales]);
      FILTER (
                    Fact; Fact[Product] = EARLIER (Fact[Product]) && Fact[PeriodID] = (EARLIER(Fact[PeriodID]) -1)
Where Fact[PeriodID] is calculated column with '=RELATED (Time[PeriodID])' formula. To my opinion this is more universal approach.
But it has the cons. EARLIER is memory demanded function. In case of 32-bit OS or numerous nested EARLIER error might occur.
Is there any alternative solution?

Similar Messages

  • How to show current year and last year sales in a WEBI Report

    Hi Guys
    How can show current YEar Sales in one column and Last YEar Sales in the other column based on a user prompt for the Current YEar Column.
    For Example is user enter 2010 for Year how can i show a Column for Sales-2010 and Sales 2009.
    Thanks

    If you can modify your Universe add an object named New Object Last Year whose SQL is:( yourTableName.Year + 1)
    Then in WebI create two distinct queries in your query Pane. In the first one you could do this:
    Query 1:
    objects: Year, Sales ... etc.
    filters:   Year Equal to '1. Prompt Year'
    Query 2:
    objects: Year, Sales ... etc.
    filters:    New Object Last Year Equal to '1.Prompt Year'
    Then in your report you can drag each object on their respective columns.
    If you don't want to use two distinct queries, use one like this:
    Query 1:
    objects: Year, Sales ... etc.
    filters:        Year Equal to '1. Prompt Year'
                 Or
                      New Object Last Year Equal to '1.Prompt Year'
    Edited by: PadawanGirl on Jun 23, 2011 6:28 PM

  • Last year sales - Urgent

    Hello Experts,
    I am trying to get a last year sales for a simple report which have year, sales. Please advise.
    Thanks,
    RC
    Edited by: user1146711 on Dec 14, 2011 9:06 AM

    1) Get three columns of your measure.
    2) In the first instance of your measure, click on the fx button and then the Filters button. On the left side pane select your Year column and set it equal to 2011. Click "OK." And this will be your measure for the current year. Call this column "Current Year Measure."
    3) In the second instance of your measure, click on the fx button and then the Filters button. On the left side pane select your Year column and set it equal to 2010. Click "OK." And this will be your measure for the previous year. Call this column "Previous Year Measure."
    4) In the third instance of your measure, click on the fx button and delete the contents. Then click on the Columns button and select Current Year Measure. (Note: OBIEE will display the SQL instead of the column name, but that's okay).) Type in the "minus sign," click on the Columns button and this time select "Previous Year Measure." Finally, add the "/" sign the asterisk (*) and then 100.0 This will then be your variance change from last year's measure to this year.
    5) On the data format of the last column, change the data format to "percentage" and you're done.

  • How to get Last Year Sales and YTD Sales without using AGO and TODATE?

    Hi all,
    I have got Company and Time dimensions and Sales Fact. My requirement is to get Last Year sales for each company without using AGO function and YTD without using TODATE function. (Due to performance issue as AGO and TODATE do not insert a Cache entry).
    Can someone please help me to achieve my requirement? Thanks in advance.

    Hi Satya,
    Thanks again for your reply. To start with I don't have data for the years 2012 and 2011 to test as I am using SH sample schema from Oracle. I have applied your solution but it does not seem to be working for the previous years like 2000, 2001. My requirement is to have a dashboard prompt "YEAR" and let the user choose whatever year he wants.
    Please have a look at the column formulas of my analysis (As per your solution) :
    ***here B_YEAR is replaced by CALENDAR_YEAR.  
    Amount: "F1 Sales"."Amount"
    AmountYTD:  FILTER("F1 Sales"."Amount" USING "D1 Time"."CALENDAR_YEAR" =YEAR(CURRENT_DATE))
    Amount LY: FILTER("F1 Sales"."Amount" USING "D1 Time"."CALENDAR_YEAR" =YEAR(CURRENT_DATE)-1)and the physical query generated by BI Server: (as you can see I have got a filter CALENDAR_YEAR= 2000)
    WITH
    SAWITH0 AS (select sum(T1074.AMOUNT_SOLD) as c1,
         sum(case  when T1035.CALENDAR_YEAR = TO_NUMBER(TO_CHAR(TO_DATE('2012-05-03' , 'YYYY-MM-DD'), 'yyyy'), '9999') then T1074.AMOUNT_SOLD end ) as c2,
         sum(case  when TO_NUMBER(TO_CHAR(TO_DATE('2012-05-03' , 'YYYY-MM-DD'), 'yyyy'), '9999') - 1 = T1035.CALENDAR_YEAR then T1074.AMOUNT_SOLD end ) as c3,
         T1035.CALENDAR_MONTH_DESC as c4,
         T1035.CALENDAR_YEAR as c5,
         T1035.CALENDAR_MONTH_ID as c6
    from
         TIMES T1035 /* D1 Time */ ,
         SALES T1074 /* F1 Sales */
    where  ( T1035.CALENDAR_YEAR = 2000 and T1035.TIME_ID = T1074.TIME_ID )
    group by T1035.CALENDAR_MONTH_DESC, T1035.CALENDAR_MONTH_ID, T1035.CALENDAR_YEAR)
    select distinct 0 as c1,
         D1.c4 as c2,
         D1.c5 as c3,
         D1.c1 as c4,
         D1.c2 as c5,
         D1.c3 as c6,
         D1.c6 as c7
    from
         SAWITH0 D1
    order by c3, c2 Thanks in advance.

  • Line Chart - Current Year Sales, Current year Returns, Last year Sales, Last Year Returns

    We have a report that summarises monthly sales & credits for 2 years in a group footer.   The footer is a sum of a formula in the detail section that calculates the monthly sales at the Item code level
    Item 1
    Group Footer 1     July     Aug     Sept     Oct          
    Sales Last Yr     @July_LY_Sales @Aug_LY_Sales     @Sep_LY_Sales  @Oct_LY_Sales          
    Credits Last Yr @July_LY_Credits @Aug_LY_Cred     @Sep_LY_Cred   @Oct_LY_Cred          
    Sales This Yr @July_CY_Sales @Aug_CY_Sales     @Sept_CY_Sales @Oct_CY_Sales          
    Credits This Yr @July_CY_Cred @Aug_CY_Cred     @Sep_CY_Cred @Oct_CY_Cred          
    <Curr Yr Graph1>
    <Last Year Graph2>
    Item 2
    Group Footer 1     July         Aug           Sept                               Oct          
    Sales Last Yr  @July_LY_Sales   @Aug_LY_Sales @Sep_LY_Sales @Oct_LY_Sales          
    Credits Last Yr @July_LY_Cred  @Aug_LY_Cred     @Sep_LY_Cred @Oct_LY_Cred          
    Sales This Yr   @July_CY_Sales  @Aug_CY_Sales     @Sept_CY_Sales @Oct_CY_Sales          
    Credits This Yr    @July_CY_Cred   @Aug_CY_Cred     @Sep_CY_Cred @Oct_CY_Cred          
    <Curr Yr Graph1>
    <Last Year Graph2>
    In the footer under the data, we want a 4 line graph (or 2 x 2 line graphs for this year & last year).  One line for sales for the current 12 months, and with it, a line plotting the credits, so as to see the trend over that year.  And then we want a line graphing the previous years sales and a line graphing the previous year credits for the 12 months. 
    On the data tab in chart expert, we selected the Place chart for each SHDOC.ITEM (Item number) in the footer and this is positioning correctly.  We have tried selecting "On change of shdoc.item and we have also tried For each record.  We selected on change of shdoc.item to generate the graph for each item.  We then added the 12 formula for the current year in the Show Value panel  
    In the show value panel we tried using the detail formula, the Report Area: Sum of <formula> and the Group 1: Sum Formula.  They all display as @July or @Aug which is a dependent formula used to identify the month
    We have added the above formula for each month and each value, but we can't work out how to group the monthly data into the 4 series of 4 lines (1 colour each) - Current Year Sales, Current Year Returns, Last Year Sales, Last Year Returns for the charting.  We have tried to create a graph with only 1 set of monthly data (viz, just 12 months current year sales) But no matter what options we take, we seem to get 12 line chart representing each month rather than 1 line representing 12 months.
    Can someone point us in the right direction?

    Please re-post if this is still an issue but search forums first, lots of chart questions have been answered.

  • Last Year Sales Report

    I have a requirement where say user selects year and months by prompts eg. 2008 jan and 2008 feb. It should also give me sales for last year and should be arranged as rows.
    2008 Jan Sales
    2008 Feb Sales
    2007 Jan Sales
    2007 Feb Sales
    How to go about it?
    Thanks

    You would need to expose another column (you can hide it, of course) that contains the month number (monthnum) equivalent (1 - 12) of the month name (Jan - Dec). Set primary sorting (1) to the year in descending order and secondary sorting (2) to the monthnum column in ascending order.
    As for getting "last year's" data from the prompt, say you have a prompt called "Year." Then you would create two "year" filters, on the Year column, as follows:
    "column name".year = @{Year}
    OR
    "column name".year = @{Year}-1
    This will pull both the "prompt year" and the year before.

  • Getting last year sale , this year sale and getting there percentage

    Hi,
    I am using three query in my report
    first query : to get this year actual sales
    second query : to get last year actual sales
    third query : to get target sales
    my first query is
    select t.branch_cd,b.branch_e_name,t.vndr#,v.vndr_name,
    sum(nvl(t.sales_actl_amt,0)) sales_actl_amt
    from inv_sales_trgt_val t,branches b,vendor v where
    t.branch_cd=b.branch_cd and
    t.vndr#=v.vndr# and
    (t.yymm between :fiscal_month and :fiscal_month2) and
    (:fiscal_month<>trunc(:fiscal_month2,-2)) and :fiscal_month2<>trunc(:fiscal_month2,-2)) and t.branch_cd between :from_branch and to_branch and
    t.vndr# between :from_vndr and :to_vndr
    group by t.vndr#,v.vndr_name,t.branch_cd,b.branch_e_name
    order by t.vndr#,t.branch_cd;
    my second query
    select t.branch_cd,b.branch_e_name,t.vndr#,v.vndr_name,
    sum(nvl(t.sales_actl_amt,0)) sales_actl_amt0 ,
    sum(nvl(t.sales_actl_amt,0)) last_year_sales_actl_amt
    from inv_sales_trgt_val t,branches b,vendor v where
    t.branch_cd=b.branch_cd and
    t.vndr#=v.vndr# and
    (t.yymm between :fiscal_month-100 and :fiscal_month2-100) and
    (:fiscal_month<>trunc(:fiscal_month2,-2)) and :fiscal_month2<>trunc(:fiscal_month2,-2)) and t.branch_cd between :from_branch and to_branch and
    t.vndr# between :from_vndr and :to_vndr
    group by t.vndr#,v.vndr_name,t.branch_cd,b.branch_e_name
    order by t.vndr#,t.branch_cd;
    and my third query is
    select t.branch_cd,b.branch_e_name,t.vndr#,v.vndr_name,
    sum(nvl(t.sales_actl_amt,0)) sales_actl_amt ,
    sum(nvl(t.sales_trgt_amt,0)) sales_trgt_amt
    from inv_sales_trgt_val t,branches b,vendor v where
    t.branch_cd=b.branch_cd and
    t.vndr#=v.vndr# and
    (t.yymm between :fiscal_month and :fiscal_month2) and
    (:fiscal_month<>trunc(:fiscal_month2,-2)) and :fiscal_month2<>trunc(:fiscal_month2,-2)) and t.branch_cd between :from_branch and to_branch and
    t.vndr# between :from_vndr and :to_vndr
    group by t.vndr#,v.vndr_name,t.branch_cd,b.branch_e_name
    order by t.vndr#,t.branch_cd;
    in second query i am created two summary column and one place holder column and one formula column to get the percentage % :
    cs_3=sales_actl_amt
    cs_4=last_year_sales_actl_amt
    cp_2
    cf_1(example :cp_2=cs_3/cs_4)
    I am getting all 100 percentage.
    in the third query i created two summary column and one place holder column and one formula column to get the percentage % :
    cs_1=sales_actl_amt
    cs_2=last_year_sales_trgt_amt
    cp_1
    cf_1(example :cp_1=cs_1/cs_2)
    Here i am getting correct percentage
    I need to get cf_1 percentage but it is getting 100 for all
    its urgent please help.
    thank you.

    Create three restricted key figures.
    In one restrict month by current month.
    In other use offset of -12 and -24 while restricting current month.

  • Last year sales volume report

    Hi BW Expert,
    I have sales report  the  current primary volume is the CKF dispalying and i have problem last year primary volume is not dispalying . i tried using offset -1(fiscal year period) the values are not diplaying .Can any one suggest how to dispaly the last year values.
    Regards
    sivaraju

    Hi,
    As you have mentioned in post, there is problem with pervious year sales volume report. Are you looking data for entire year, in that case you should offset for fiscal year -1.
    Also you are looking only for one period of pervious year, offset with -12 not with -1. If those restrictions are correct, check if you have fiscal year variant included in query. For offset to work proper you should have the fiscal year variant field in the query.
    only then offset will work fine.
    Hope this helps
    Regards
    Akhan

  • Report on Current and Last Year Sales

    Hi ,
    I have a requirement to create a report which would display in one column sales from current fiscal year/period and 2nd column sales from last fiscal year/period at the same time
    Please guide.

    Hi,
    You can achieve this by creating two selections in columns in query designer.
    First one restrict the key figure with current Fiscal period.
    Second restrict the key figure with Fiscal year with customer exit and -1 as offset value.
    Hope this helps........
    Rgs,
    Ravikanth.

  • How to get Current month last year sale in report

    HI,
              I would like to compare the sale value of a  month for any year.
    ie sale of the march month for this year ,previous year and a year before ..like that
    at least for two years..ie current and prvious year.
    how can i get it done in query?
    thnx

    Create three restricted key figures.
    In one restrict month by current month.
    In other use offset of -12 and -24 while restricting current month.

  • FI-SD data-BEx Query Logic for Amount received for the Lasts F.Year Sales

    Hi Friends,
    Need your assistance in designing one BEx Query,
    We have Two cubes...one is sales ZSALES01 and Account Receivables ZFIAR01. On top of these cubes e built Multiprovider.
    In the sales cube (ZSALES01)., we have calender day, Financial year , Fiscal period characteristics as time characteristics and Net Values as key figures. And Same way in the Account recievable cube (ZFIAR01) we have calender day( Which is mapped with Posting date), Financial year , Fiscal period characteristics as time characteristics and Credit/Debit amount as key figure.
    My requiremnt is that i have to show in BEx with below scenarios.......
    1.Amount received for the sales occured till Last Financial year
    2. Amount Received for the sales occured in this current financial year
    We have two show these values for company code wise , we have company code in both cubes nad we  have financial year...and some other common fields there in both cubes.
    Can you please guide me how to design the same in BE query.
    Thanks & Regards,
    Anand

    are you saying that in your query you need to have 4 columns;
    - Sales Last Year
    - Sales Current Year
    - AR for Sales (LY+CY)
    - AR for Sales Current Year
    If yes, getting Sales Information is easy. You need to use customer exit variable to get the current year (calendar or fiscal)
    - for Sales Last Year, use customer exit variable for current year with a offset of -1
    - for Saels Current Year, use customer exit variable for current year
    For AR columns, as I said in my earlier post - use a lookup while loading data in AR cube. Use the Sales Doc Number and get the year information (calendar, financial or fiscal - whatever you want to use depending on your requirement) from Sales flow. This way you can tell if a particular FI doucment is for this year's sales or last year's sales.
    Now, you can use another customer exit variable for AR column depending on the "Sales Year" infoboject. Customer exit variable shold be populated with the current Sales Year.
    - for AR for Sales CY, use this customer exit variable
    - for AR for Sales LY, use this customer exit variable with offset of -1
    - AR for Saels (LY+CY), add both the columns above
    Another way of achieving AR for Sales (LY+CY) is to restrict the RKF or value range using customer exit variable for Sales year with BETWEEN operator (From var1 to (var1-1)).
    You can also use the option of replacment path variable as Durgesh mentioned. but in that case you will have to create two addition queries based on sales data which will return:
    - sales documents for last year
    - sales documents for current year
    then you need to create two replacement path variables for AR columns which will get values from these two queries.
    I hope it helps.
    Regards,
    Gaurav

  • Want to create analysis for this year week vs last year week

    All,
    My requirement is to create an analysis for the passed week number of this year vs same last year week no.
    So basically user will pass the week no. and report should display the passed week no. this year sales number plus same week no. last year sales number.
    How can I achieve this?
    Thanks

    If you ask like this ..I would say like using presentation variable for week
    use measure with exp like
    CASE WHEN WEEK=@{WK} AND Time.year=VALUEOF("PREVIOUS_YEAR") THEN #sales END.
    In this case week is from your subject area and PREVIOUS_YEAR is rep variable you might have it.
    there are other options to get output, need details about your rpd and value of week.

  • Actual and Previous year Sales Figure comparison

    Hi,
    I have a WebI report in which i have a requirement :
    Comparison of the Current year and Last year Sales Value and we have a filter on Year Value .
    i.e. Let suppose i selected year 2010 as a year filter then i want to compare the sales figure of 2010 and 2009 ( i know about the limitation of WebI that it cannot Query back) so once i selected a year filter 2010 my data will be scoped to 2010 only and we cannot get the data for 2009.
    So any work around for the above scenario and we are using Universe based on OLAP cube so any MDX function on universe will effect the performance of my report so i dont want to change much at Universe level.
    Regards,
    Mishra Vibhav.

    Hi,
    iam sure you would be knowing this that You can achieve this using query filters with between operator,where you can provide the range.
    if not how about using formula's option in the report
    Swapna.G
    Edited by: swapna gollakota on May 26, 2010 2:08 PM
    Edited by: swapna gollakota on May 26, 2010 2:14 PM

  • Last Year Inovice Total need to be calculated in a new column in OBIEE 11g

    Hi,
    I have a measure Net Invoiced Amount, and now my client is asking to get a new column in which last year's Net Invoiced Amount total needs to be calculated.
    We need to select the Dates dynamically, it is 2012, so the column should the invoiced amount total for 2011, if it is 2013 then amount should be 2012. Can we do this in RPD. If so, please tell me how.

    Hi,
    Method1:
    TIMESTAMPADD( SQL_TSI_DAY , -1, TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM DATE Column) * -(1) + 1,
    DATE Column))
    Note: create alias table from your fact (call it as fact table name_YTD) Join th aliases to the dimension tables exactly like how your normal fact table is joined to the aliases, except for the time dimension.
    Method 2: by using Time series functions (Ago fxn)
    Ago(<<Measure>>, <<Level>>, <<Number of Periods>>)
    Example:Ago("Human Resources"."Fact - Absence"."# Days" , "Human Resources"."Time"."Year" , 1)
    Method 3: if your using obiee11g --> from analysis itself you cand solve it
    AGO(expr, [time_level], offset)
    Thanks
    Deva

  • Calculating this month of last year revenue

    Hi,
    i am preparing a new dashboard like below
    month total revenue total revenue of last year (january - 2011)
    january 125.00 120.00
    can you please share your experience how can i do this?

    Hi,
    If you always want to show the previous years data (ie not only last year, but last two/three/.. years) then you can use AGO function in
    RPD.
    Refer for AGO-
    http://gerardnico.com/wiki/dat/obiee/ago
    OR,
    But if you are using for a single last year then in the column formula use - 'January'||cast(year(current_date)-1 as char)
    (If its always January you want)
    Hope this helped/ answered.
    Regards
    MuRam
    Edited by: MuRam on Jun 12, 2012 5:08 AM

Maybe you are looking for

  • S_ALR_87012309

    Hi We are using S_ALR_87012309 report for checking daily balances of Bank account also. But one Foreign currency transaction of this Bank account shown properly in Local currency but the daily balances and carry forward values are not matching with t

  • How to update Logic Pro 9 to Logic Pro X..!

    I bought the App. (Logic Pro V.9) in April. I'm trying to update it to the V.10 (Logic Pro X) , but i had been asked to re-buy the App..! Please, advise how to update..! by the way, i already updated My MacBook Pro to OS X Mavericks Regards,

  • How to link within a spry data set?

    Hi everybody, I am working with DW CS4 and want to know how to insert a link to another html site within the Spry data set. All I am archieving at the moment is to write the hyperlink-addy as plain text on my website. I have this kind of structure in

  • Having trouble re-loading Mac OS X to mac mini.

    I recently recieved a hand-me-down mac mini which was in "server mode". I tried to re-load Mac OS X, choosing to archive the old server data just in case the original owner wanted it back. But after the first CD has run its course, the mini goes thro

  • Conversion from iPhoto (oh, not again)

    Before asking my question let me start by thanking all the regular contributors to the Aperture forum, and in particular Terence Devlin, Kirby Krieger and Frank Caggiano. Your posts have been more valuable to me than any book I bought or any course I