Sales Summary - Compare same weekday sales last year.

Post Author: geoffh
CA Forum: Formula
I have a table storing invoices going back several years. I wish to calculate the total sales for yesterdays date, & compare it with total sales for the same weekday in the previous year. For example if it is Tuesday today, I need to calculate Mondays total sales (yesterday) & also Mondays total sales for the same week period last year.
Date fields I have available are 'history.date_invoiced' (invoice date) , history.week_invoiced , history_year.invoiced. Sales values are history.sell_account & history.sell_cash.
I'm new to crystal.......Using V 11.0.0.1282 . Any help would be greatly appreciated.

Post Author: yangster
CA Forum: Formula
create a formula with the following informationnumbervar weeknumber_curr_year := datepart("ww", dateadd("d", -1, ));numbervar weekdaynumber_curr_year := datepart("d", , 1);  //assuming sunday is the start date of the week, change to 2 if monday isthose 2 variables will tell you the current week number and what day of the week you are after for the current yearnumbervar last_year := dateadd("yyyy", -1, currentdate);if year() = last_year and datepart("ww", ) = weeknumber_curr_year anddatepart("d", , 1) = weekdaynumber_curr_year then amt_field else 0put that in the details section and create a summary of the formula and you should have the total sum of sales for exactly the same week and day of week one year prior to yesterdaymaybe kai has a more simplified solution but that's what comes off the top of my head

Similar Messages

  • Query with the days of a period and the same days of last year

    I need a help.
    We have a sales cube with daily values.
    We have a query that restricts a month (0CALMONTH) and shows the daily values for this month.
    No problem, we have only to put 0CALDAY on the line and the value on the columns.
    But we need also to show the values of the same days from last year.
    Example:
    The restricted month is july/2011.
    0CALDAY is on the line, so the query shows the values for
    01.07.2011   110,00
    02.07.2011   108,00
    31.07.2011   109,00
    How can we show in the same line the values for july/2011 and july/2010?
    Example:
             July/2010    July/2011
    01     95,00            110,00
    02     96,00            108,00
    31    94,00             109,00.
    Thanks in advance
    César Menezes

    Thanks for the answers until now.
    Surely a Day characteristic (ex. CA_DAY, derived from 0CALDAY) would work.
    But we have this requirement in many other cubes (I posted only an example) and it's not feasible to create this characteristic now.
    I understood the other suggestions, but the problem is not on selecting the values.
    We have two restricted key figures, one for a period (filled by the users) and another one for this period - 12.
    They work OK and bring the correct results.
    The problem is on presenting the results, because as we have 0CALDAY in the line the results appear on two different lines.
    Example:
    15.07.2010    950,00
    15.07.2011    980,00.
    Is ther any way to present the results in the same line?
    Example:
    15.07.2011    950,00 (last year)     980,00 (today)
    or
    15.07             950,00 (last year)     980,00 (today)
    or any other way?
    César

  • New Releases Section is the same for the last year

    As the title says the "New Releases Section" in the "Browse" all the platforms (desktop, android, web and iOS) is absolutely the same for the last year. It is never updated but why as I can clearly see my album notifications from artists I follow? Is this section a "sponsored" artists only secrion, whats the deal here? Here is a screenshot of how the section looks today 30.4.2015, notice that Rammstein which added their music almost and year ago is still occuping most of the space.

    You will not believe the response I got, I am waiting on an escalated response as what they told me is unacceptable at least for me. I will remove the Spotify support person's name as it is not his fault and I don't want to get anyone in trouble for a bug that he/she did not make: Hi ...,
    Thanks for your feedback. You mentioned that you're still seeing the same artists from last year in the New Releases section.
    Can you please try to login Spotify using these details and tell us if you're still seeing the same artists/albums?:
    Username: ...
    Password: ...
    Let us know right away if you are seeing new artists and albums. If you are, then creating a new account may be necessary.
    We'll wait for your response.
    Have a nice day, to that I responded: When I log-in with that test account the New Releases is different and is up to date. Are you serious that I need to create a new account to fix this, this is unacceptable. I WILL NOT leave my entire music library and my premium subscription history in order to fix a clear bug in your system, I am better of leaving Spotify all together. Please escalate this issue to your managers as it is again UNACEPTABLE to require me to create a new account to resolve a clear bug in your system, what is next if this gets stuck again down the road in 3 months will you ask me to create new account again, till what end. I am shocked at this. I have not idea what is happening at Spotify quarters but the last 5 months have been a pure pain, starting with the 10 000 limit of Your Music, than the 1.0 desktop version disaster and now this absurd "solution". I have been a loyal paying customer for over and year and now I feel like I wasted this time supporting a company that was not worth it. Edit: If such an issue cannot be resolve by Spotify and the only solution is to create a new account I can't even imagine what "spaghetti code" is the core implementation of their service.

  • How to compare this week with last years week sales ?

    Hi all,
    I have a table called Sales with two columns  Date and UnitsSold
    Date is of type smalldatetime   and will have the date of the sales
    while UnitsSold is type int and will have the number of units sold
    I need to write a stored procedure that will compare between a week's sales from last year with a week sales from this year and show the percent in sales difference
    Thanks

    DECLARE @thisYearThisWeekStart DATETIME = DATEADD(DAY,1-DATEPART(weekday,'2014-01-01'),DATEADD(WEEK,DATEPART(WEEK,GETDATE())-1,'2014-01-01'))
    DECLARE @thisYearThisWeekEnd DATETIME = DATEADD(DAY,0-DATEPART(weekday,'2014-01-01'),DATEADD(WEEK,DATEPART(WEEK,GETDATE()),'2014-01-01'))
    DECLARE @lastYearThisWeekStart DATETIME = DATEADD(DAY,1-DATEPART(weekday,'2013-01-01'),DATEADD(WEEK,DATEPART(WEEK,GETDATE())-1,'2013-01-01'))
    DECLARE @lastYearThisWeekEnd DATETIME = DATEADD(DAY,0-DATEPART(weekday,'2013-01-01'),DATEADD(WEEK,DATEPART(WEEK,GETDATE()),'2013-01-01'))
    DECLARE @thisYear INT, @lastYear Int
    DECLARE @salesTable TABLE (date DATE, unitsSold INT)
    INSERT INTO @salesTable (date, unitsSold)
    VALUES
    ('2013-07-07',10),('2013-07-08',9),('2013-07-09',8),('2013-07-10',7),('2013-07-11',6),('2013-07-12',5),('2014-07-13',4),
    ('2014-07-06',12),('2014-07-07',13),('2014-07-08',14),('2014-07-09',15),('2014-07-10',16),('2014-07-11',17),('2014-07-12',18)
    SET @thisYear = (SELECT SUM(unitsSold) AS tUnitsSold FROM @salesTable WHERE date BETWEEN @thisYearThisWeekStart AND @thisYearThisWeekEnd)
    SET @lastYear = (SELECT SUM(unitsSold) AS tUnitsSold FROM @salesTable WHERE date BETWEEN @lastYearThisWeekStart AND @lastYearThisWeekEnd)
    SELECT @thisYear AS thisYear, @lastYear AS lastYear, CONVERT(float,ROUND(((@thisYear+.0)/@lastYear)*100,2))
    You should really use a calendar table.

  • Compare same first and last name that exists in 2 different rows!

    Dear All,
    I am using Oracle 11gR1 on Linux OS.
    I have a table that stores employee_id, emp_first_name, emp_last_name, hire_date
    The records may be like this:
    14210, imran, baig, 12-MAR-10
    10673, mobeen, ahmed, 14-MAR-10
    10060, saad, qureshi, 16-MAR-10
    6902, abdul, aleem, 18-MAR-10
    33652, imran, baig, 22-OCT-10
    55522, mobeen, ahmed, 22-OCT-10
    I need the output in this format: same names are to be shown in one row with old and new hire dates and IDs.
    14210, imran, baig, 33652, 12-MAR-10, 22-OCT-10
    10673, mobeen, ahmed, 55522, 14-MAR-10, 22-OCT-10
    Thank you very much.
    Regards, Imran

    Hi, Imran,
    If there will be (at most) only two rows with the same name, then you could do a self-join.
    If there could be a variable number of rows with the same name, then you probably need String Aggregation . The following page shows several techniques for doing string aggregation:
    http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php
    LISTAGG, as Pavan Kumar suggested, is the best of these. Unfortunately, it doesn't work in versions earlier than 11.2.(That's why the site mentions the others.)
    If the order or the output is not important, then I recommend the user-defined aggregate function, called STRING_AGG on that site, but called STRAGG by most people.
    If the order of the output is significant, then I recommnend the SYS_CONNECT_BY_PATH approach.
    If you'd like help, post a little sample data (CREATE TABLE and INSERT statements), and the results you want from that data, formatted between \ tags.
    In the future, if you have a question like "How can I write a query to ...?", you should post it in the SQL forum:
    PL/SQL
    You'll propably get better response there.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • SQL Query-return current month and the same month of last year

    hello-
    I would like to display the current month name, count of errors, year, and month number for both current year and previous year. Having trouble getting my query to display as following..... 
    Month   CountofErrors      Year      MoNo
    January                  57    2015          1
    January                 155   2014          1
    thank you!

    Its hard to answer without DDL and DML and sample data.
    Give a try
    select DATENAME(month,getdate()),Month(getdate()),YEAR(getdate()) ,COUNT(*) from dbo.errortable
    where DATENAME(month,getdate())='January' and YEAR(getdate()) in(YEAR(getdate()),YEAR(getdate())-1)
    group by DATENAME(month,getdate()),Month(getdate()),YEAR(getdate())
    --Prashanth

  • 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.

  • How to load member for "sales same date last year"?

    I need to load a member in Measures named "PriorYrSales" with "Sales" for the same date last year as today's date. Thus, retrieving "PriorYrSales" for 2/10/2002 would return the sales amount for 2/10/2001. Since days roll-up to months, quarters, years, it would be easy to determine how we're doing compared to the same time last year.Data is loaded each day for a date range from the current date and the preceding x days. Substitution variables are available for the beginning and ending date and the same dates for last year.For example: Data is loaded from beginning date of 2/01/2002 through ending date of 2/10/2002.The prior year date variables contain 2/01/2001 and 2/10/2001.The time period dimension is as follows:FY01->Jan2001-->01012001 (Alias: 1/01/2001)-->01022001 (Alias: 1/02/2001)-->all the dates in Jan->Feb2001-->02012001 (Alias: 2/01/2001)-->02022001 (Alias: 2/02/2001)-->all the dates in Febetc.FY02->Jan2002-->01012002 (Alias: 1/01/2002)-->01022002 (Alias: 1/02/2002)-->all the dates in Jan->Feb2002-->02012002 (Alias: 2/01/2002) -->02022002 (Alias: 2/01/2002)-->all the dates in Febetc.Thanks your any and all suggestions.Phil

    Perhaps I wasn't clear in the first post. The intent is to easily compare sales for a current date/period to the same date/period last year. Neither Excel nor Analyzer provide a method that I'm aware of to retrieve data as follows:-------------------------------------Period Sales PriorYrSales Diff4/15/2002 1,000 900 100-------------------------------------(900 is sales for 4/15/2001)(100 is the calculated difference.)Nor can I do this:-------------------------------------Period Sales Period Sales Diff4/15/2002 1,000 4/15/2001 900 100-------------------------------------What Excel and Analyzer do allow is:-------------------------------------Period Sales 4/15/2002 1,0004/15/2001 900-------------------------------------I readily acknowledge that the data is redundant but I can't think of another option that will allow Excel and Analyzer to easily retrieve the values for comparison. If the PriorYrSales member can be loaded then the users can compare years, quarters, months and days quite easily.My challenge is knowing how use a calc script to derive prior year dates that correspond to current year dates. Something like:PriorYrSales->04152002 = Sales->04152001I've considered arrays but I've never used them and the documentation is not helpful enough for me.Thanks for your response.Phil

  • Compare month sales with previous year same month sales

    hi all.
    we need to compare given month of this year with same month of last year. we need to compare sales quantity and value.
    the query is on 0RT_C40 multiprovider. We have tried all options using 0Calmon, calday, fiscal year... but whenever we specify offset, we are not getting data. there is valid data for previous year.
    plz let us know what else to do? check with 0RT_C40.
    thanks in advance.
    regards: gaurave

    Gaurave,
    Are you selecting the time period in a selection in columns or rows, or are you selecting the time period in the Filter or Free Characteristic area.
    When you make the initial selection of say Period 11.2007 in the Free Characteristic area, and then within a selection but on an offset to derive 11.2006, the fact that you have made your selection of 11.2007 in the Free Char area will restrict the entire query results to this time period.
    Both your picks on time should be in selections in the Columns or the Rows.
    Regards
    Gill

  • How to calculate "same store sales"

    Hi,
    What's the best way to do "same store sales" type calculations in OBIEE? The star schema I'm working from has a "sales" fact that just includes sales per product per store per day. And our "store" dimension includes a "store open date".
    I'm just not sure of the best / fastest / easiest way to do same store sales in OBIEE. Any ideas would be greatly appreciated!
    Thx,
    Scott

    I assume you have a sales date in your fact ... you could alias your fact table to have Fact-Sales and Fact-Sales(YAGO) and then you could have Sales and Sales YAGO columns ... then in your Request select Store and Sales where Sales YAGO > 0 ... I work for a Grocer and our same store sales is a little more complicated where the actual definition of the same store can be overriden so we have a store/week/flag dimension table in addition to the Store dimension and Sales fact tables. We then select Store, Sales, Week where flag =Y ... this gets us the stores designated as same stores and not just stores with sales for the corresponding week(s) last year. We also put the current year and ly sales in columns on one row in the sales fact table so we can do a few different things such as the stores with sales last year (though that isn't the norm).

  • Unable to burn DVDs on iMac. Folders dragged to DVD window appear as documents. DVDs from same package burned OK last year. Using Lion. CDs burn OK.

    Unable to burn DVDs on 2009 iMac ( Lion ). Folders and any files dragged to DVD window appear as blank documents.
    Burned DVDs from same package ( Memorex ) last year OK. CDs burn OK. DVDs are several years old, if that matters.

    The music is a tune that was purchased/downloaded from the iTune store. The slide shows (five of them) consist of digital photos (jpg) that I have taken. The interesting thing is that I also have an eMac (about three years old) that I have created the same iDVD project (identical music & identical slide shows). I have been able to burn a DVD disk of this project on my eMac WITHOUT A PROBLEM. The thing I do not like about the eMac is that I purchased family pack of iLife 6 last year (because I liked some of the new Themes). However, when I installed it on my eMac, for some reason it takes about 5-10 minutes to get iDVD 6 "up and running." Once it has loaded the Themes, however, I am "good to go." I've had this computer into the "Genius Bar" at the local area Apple Store TWICE and they are unable to get it to work more efficiently. The even reinstalled the entire operating system to no avail. So, the solution is to launch iDVD 6 on my eMac and then go do something else for 5-10 minutes. But at least I am able to burn my iDVD projects to DVDs.
    With my iMac, iDVD launches quickly but is useless since I am unable to burn my iDVD slide show projects to DVD.
    So, as a result, I am pretty much ready to "call it a day" with the iMac and will go back to my eMac.
    Thanks for your time.
    SCC Jeff

  • 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

  • A simple query to show sales versus last year on daily basis/

    Hi guys,
    I want to build a simple query with day (1,2,3,4,5,6) on the rows and "sales current year" and "sales last year"
    on the columns.
    I have only 0CALDAY in my cube.
    How can I have on the rows the day in stead of the full date?
    I would like to see in the sames row sales current year and sales last year.
    Thanks
    Shlomi

    HI Shlomi
    Create a virtual characteristic in your infoprovider that can calculate the day from calendar Day. In ZXRSRZZZ while adding code for this virtual characteristic use the function module DATE_COMPUTE_DAY to compute the day for every calendar day.
    For calculating Sales Current year, create a restricted ky figure with Sales as the key figure. Add 0CalDay to this RKF and create a variable for this infoobject(Eg: ZCURYEAR) that will receive input from the user for the range of dates eg: 08/16/2009 - 08/22/2009.
    For Sales Prior year, create another restricted key figure with Sales. Add 0CalDay to this RKF and add a customer exit variable. In the Customer exit code use the ZCURYEAR variable and offset it to prior year in both the upper and lower limits. This should work.
    I hope this helps.
    Thanks.

  • How to get YTD sale for Last year In OBIEE 11g

    Hi All,
    I have a fact table for Sale_Amt with doc_date wise details. It is connected to Simple time_dimension table based on Date_ID(Number) field. The time_DIm Hierarchy is set on Year, Quarter, Month fields of the time_dimension table.
    One of my reporting requirement is to show show YTD sales and Last Years YTD sales.
    e.g, If user select 23 Jul 2013 as the date parameter, I need to show 1-Apr-2013 till 23 Jul 2013 Sales in YTD column and 1-Apr-2012 till 23 Jul 2012 Sales in Year_Ago_YTD column. I am able to get YTD sales but unable to derive at Year_Ago_YTD sales figures.
    Finacial Year Start from 1st April till 31 March.
    Any Help on this will be appriciated.
    Thanks.
    Narendra Shetty.

    Narendra,
        You can make use of the below two functions to get the year ago dates. You can replace current_date with a presentation variable that stores the date parameter that user selected.
    TimestampAdd(SQL_TSI_YEAR,-1,TIMESTAMPADD(SQL_TSI_MONTH, 3,TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE))) - It will display previous year's first day of fiscal year (since I passed current_date, it gives you 1st april 2012)
    and
    TimestampAdd(SQL_TSI_YEAR,-1,current_date) - Same Day Last year
    Pls mark correct/helpful.

  • 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.

Maybe you are looking for