YTD & PTD

Hi,
How i can able to identify YTD and PTD column in my fact table in obiee 11g. How i need to perform YTD and PTD analysis.
Is there any stepwise document of performing these analysis from the scratch.
Thanks
GTA

Hi Peak,
Thanks for your reply, In my time dimension i have the following hierarchy
H1TIME
year
quarter
month
week
day
So, it is necessary to set the chronological key for each level of time series is okay. And also for (Year to Date) i can calculate using the "year" level as it is available in my time hierarchy.
But for (Period to Date) there is no specific like period level as you said, so in this case which level i need to take it as a period level.
Can you be more elaborate for helping me in calculating PTD in my scenario.
Thanks for your support.
All izz Well
GTA

Similar Messages

  • Ytd,ptd,qtd in dashboard prompt

    Hi
    how to use ptd,qtd,ytd as dashboard prompt
    i created netamount ptd,ytd,qtd in rpd
    my metric is netamount
    in dashboard if i select ptd then give ptd values
    selct ytd give ytd netamount
    qtd also same
    its in dashboard change all the reports in dashboard
    how to do this

    First try with single report and test whether its working. later you can implement for all the reports.
    Create Measssure
    "Your_table_name"."ptd" = Somr calculation i rpd
    "Your_table_name"."qtd" = Somr calculation i rpd
    "Your_table_name"."ytd" = Somr calculation i rpd
    Now you have 3 measures in the presentaion layer called ptd,qtd,ytd.
    Create report put the column like "Your_table_name"."@{var_mes}{ptd}" ( ptd as defalut meassure) save the report.
    Now create Dashboard Prompt . In that select Variable Prompt. In the right side of Presentaion Variable write as var_mes.
    Now select choice list then custom values, select values enter ptd .
    select values enter qtd and again ytd...........
    Now u have a presentation variable with 3 custom values , ptd,qtd,ytd
    Save the dashboard prompt.
    Put this dashboard prompt and Report in saingle dashboard. imitaialyy your report should show the value of ptd ( coz you have select ptd as default above in th column formula "Your_table_name"."@{var_mes}{ptd}" )
    Now wheh u cahnge the prompt, presentaion vraibale should go and maessuare should change.
    mark if correct/helps
    fiaz

  • MTD,YTD,PTD without calendar table

              QTY
          Month
          Year
    QTY_YTD
    QTY_MTD
    QTY_PTD
    10
    1
    2010
    20
    2
    2010
    20
    1
    2012
    30
    3
    2012
    Above is how my table looks like and  all are having integer datatypes
    I dont have a calendar table to join hence without calendar table can I compute YTD,MTD,PTD?
    If so what will be the case queries
    Mudassar

    Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. Temporal data should
    use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect. 
    This is minimal polite behavior on SQL forums. 
    Since SQL is a database language, we prefer to do look ups and not calculations. They can be optimized while temporal math messes up optimization. A useful idiom is a report period calendar that everyone uses so there is no way to get disagreements in the DML.
    The report period table gives a name to a range of dates that is common to the entire enterprise. 
    CREATE TABLE Something_Report_Periods
    (something_report_name CHAR(10) NOT NULL PRIMARY KEY
       CHECK (something_report_name LIKE <pattern>),
     something_report_start_date DATE NOT NULL,
     something_report_end_date DATE NOT NULL,
      CONSTRAINT date_ordering
        CHECK (something_report_start_date <= something_report_end_date),
    etc);
    These report periods can overlap or have gaps. I like the MySQL convention of using double zeroes for months and years, That is 'yyyy-mm-00' for a month within a year and 'yyyy-00-00' for the whole year. The advantages are that it will sort with the ISO-8601
    data format required by Standard SQL and it is language independent. The pattern for validation is '[12][0-9][0-9][0-9]-00-00' and '[12][0-9][0-9][0-9]-[01][0-9]-00'
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • PTD and YTD in GL

    Hi,
    I have to display accounting information on my report. I'm new to GL. Does anyone knows how to calculate PTD and YTD in GL. I need to know the technical details. I'm aware of the tables but don't know the formula to calulate PTD and YTD.
    Please help.
    Thanks and Regards,
    Ravindra

    Hi;
    Please review:
    YTD & PTD
    YTD & QTD Calculation through Calculation Script
    Regard
    Helios

  • Fast Formula are not verified while upgrading to R12

    Dear All
    As we are upgrading from 11.0.3 to R12, some formulas are not verifying.
    The formulas which are all linked with the leave balance or ITD,YTD,PTD, Asg_run etc..are not verified.
    Error Message for your information:
    APP-FF-33062: Line 21: Alias for STOP_SALARY_DAYS_IN_PERIOD_ASG_RUN not allowed. Can only alias globals and DB items
    Cause: You have tried to alias a formula variable that was not a global or a database item
    Action: Only alias items whose name you cannot change such as database items or global variables
    Thanks in Advance
    Regards
    Nakshatra

    Hi IIaria
    As you said when we create a balance , dynamic database item will be created automatically.But when we upgraded from oracle 11.0.3 to R12, the balance was already created.
    The formula is not validating this as a balance but as a local variable,as you said.
    So Instead of alias I tried to declare the variables directly, still it says error
    APP-FF-33064: Line 1: Statements are ordered incorrectly.
    Even i tried to change the order but nothing works.
    I tried to run the Generate run balance with the mode as "All Invalid Balance"
    it is asking for "balance level"( Mandatory) but there is no LOV.
    Kindly guide us.
    Regards
    Nakshathra

  • Alternate Calendar for limited scenario

    Hello,
    I have a user who does reporting using COPA data.  We have a 4-4-5 fiscal year variant, and Period 1 corresponds to January, Period 2 corresponds to February etc.
    For this particular users purpose they need to analyze the data in a way that Period 1 corresponds to August, Period 2 corresponds to September.
    How can this be done?  Ideally our existing variables would work as well.  Such as YTD, PTD, Prior year etc.
    Any help would be appreciated!
    Thanks,
    Nick

    Nick,
       As you said, You can achive your requirement using Different Fiscal Year Variant.
    August or Sept etc. all are Calender Months. We will calculate fiscal periods using Fiscal Variant and Calender Month. Check with SAP R/3 Controlling or Fi guy can help with required Fiscal Year Variant or they will create one in either in BI or SAP R/3.
    Let me know wheather new Fiscal Year variant Helped you or not.
    All the best.
    Regards,
    Nagesh Ganisetti.

  • Original and current budget together with PTD,ITD,MTD and YTD labor...

    Hi experts:
    I need a Project Accounting Report that shows Original and Current budget together with PTD,ITD,MTD and YTD labor amount, labor cost, non-labor cost, and revenue on the same line for all the task_id for a project. I know these are coming from these ,PA_BUDGET_VERSIONS V, PA_RESOURCE_ASSIGNMENTS A,PA_BUDGET_LINES L, main tables. But I am unable to break down the amounts according to PA and GL periods. Can anyone help please?
    Thanks a million , in advance.

    Help you with what?
    No database version number.
    No application name or version number.
    No DDL.
    Do you, for some reason, think we have any idea what PTD and ITD are? If so why?
    Do you think we all have your version of a table named PA_RESOURCE_ASSIGNMENTS on our hard disks?
    Perhaps you have some version of e-Business Suite. Perhaps you have SAP. Perhaps you have something we've never even heard of.
    Your task is as follows:
    1. If this question relates to an Oracle product change the subject of the post to "Please Ignore" and post your question in the correct forum.
    or
    2. Provide us with sufficient information that we can duplicate those portions of your environment required to understand what you are asking.

  • Consolidation PTD/YTD

    On Consolidation Transfer Window you have the option to choose Amount Types (PTD/YTD)
    What I understood from this is you can consolidate either PTD or YTD balances (beside other types).
    I can see how PTD consolidation would work. PTD balances would be sent over to the Parent Ledger. Parent Ledger's YTD would be derived from this PTD activity.
    What I don't understand is that how YTD consolidation looks like? How would PTD balances be derived in Parent Ledger?
    Let me rephrase my question:
    Shouldn't always period net activity (PTD) be transferred over to the parent? All other balance types like YTD, QTD etc would be derived from this period net activity? If we transfer YTD instead then how would period net activity be derived in parent?

    A few things:WHat problem are you having with DTS? The calculation you describe looks like it could be solved with DTS without adding calculation overhead.Second, rather than create a new dimension, you could create an alternate rollup in your existing dimension, and use shared members to create the to-date totals.If you want to use a new dimension, you need 3 members in it, not 2:To Date - data - YTD - PTDYou need a placeholder to load the data into, then 2 members to apply the to date calculation to.The formula on YTD could look something like this:IF (@ISMBR (Jan)) YTD = data->Jan;ELSEIF (@ISMBR (Feb)) YTD = @SUMRANGE (data, Jan:Feb);... etc...ELSE YTD = @SUMRANGE (date, Jan:Dec);ENDIFThe formula takes the values stored in the data member and sums them across the appropriate range of months. The function for PTD could be similar, with slightly different logic.Hope that helps.Regards,Jade---------------------------------Jade ColeSenior Business Intelligence ConsultantClarity [email protected]

  • Amend previous solution for YTD totals:  need PTD also

    Last week I received help on getting YTD totals on a 5 week period-to-date report. Data and solution are below.
    I've got a period to date report with following columns:
    week1 tots, week2 tots, week3 tots, week4 tots, week5 tot, period-to-date tots, year-to-date tots
    The records for one hot dog stands looks like in the following format:
    HOT_DOG_STAND_ID       WEEK_NBR               NET_SALES2             BUNS24434              PICKELS_AW38           MUSTARD_TB56           CHICKENHEADS33         PIECES_SOLD34          SCRAPS35               PIECES_UNACCOUNTED     HEAD_AVERAGE           EFFICIENCY            
    141                    0                      647064.59              691287.4               149142.91     
    141                    1                      697227.09              694887.4               139149.31             
    141                    2                      293067.04              344887.4               159159.91             
    141                    3                      693467.09              695687.5               139149.91             
    141                    4                      644067.09              595487.4               635149.94 
    141                    5                      644067.09              595487.4               635149.94               
    141                    7                     6897467.09            12694887.6             34139169.34                                Week nbr 0 is sum of weeks from beginning of year to the end of previous period
    week 1 - 5 are the totals for each week in the period
    week 7 represents the the year to date total
    (totals for #7 are only for display and are not correct)
    I was not concerned with PTD totals (sum of weeks 1 to 5); I simply UNION ALL'ed a second SELECT from first query summing on week 1 - 5
    The client program throws error:
    "unsupported case for inlining of query name in WITH clause". Googling suggest it is most likely most likely because of the UNION ALL
    So I do need to get the PTD totals in a record with Week number 6.
      CREATE TABLE PERIOD_DATA
       (     "HOT_DOG_STAND_ID" NUMBER NOT NULL ENABLE,
         "WEEK_DATE" DATE,
         "NET_SALES2" NUMBER,
         "BUNS24434" NUMBER,
         "PICKELS_AW38" NUMBER,
         "MUSTARD_TB56" NUMBER,
         "CHICKENHEADS33" NUMBER,
         "PIECES_SOLD34" NUMBER,
         "SCRAPS35" NUMBER,
         "PIECES_UNACCOUNTED" NUMBER
    REM INSERTING into PERIOD_DATA
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('29-DEC-08','DD-MON-RR HH.MI.SSXFF AM'),14301.39,13951.26,3431.13,0,3680,2484,378,818);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('05-JAN-09','DD-MON-RR HH.MI.SSXFF AM'),14651.37,14651.37,3249.55,0,3200,2419,505,276);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('12-JAN-09','DD-MON-RR HH.MI.SSXFF AM'),14169.89,14169.89,2463.53,0,3136,2080,474,582);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('19-JAN-09','DD-MON-RR HH.MI.SSXFF AM'),15864.46,15864.46,3245.49,0,3472,2764,475,233);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('26-JAN-09','DD-MON-RR HH.MI.SSXFF AM'),15961.2,15916.23,3395.51,0,3648,2838,392,418);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('02-FEB-09','DD-MON-RR HH.MI.SSXFF AM'),19066.4,19066.4,4165.07,0,4336,3682,333,321);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('09-FEB-09','DD-MON-RR HH.MI.SSXFF AM'),18415.74,18415.74,4024.74,0,4032,3365,482,185);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('16-FEB-09','DD-MON-RR HH.MI.SSXFF AM'),18014,17849,3486.33,0,3840,3238,374,228);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('23-FEB-09','DD-MON-RR HH.MI.SSXFF AM'),18671.09,18626.12,3729.42,0,3888,2970,353,565);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('02-MAR-09','DD-MON-RR HH.MI.SSXFF AM'),17636,17636,3815,0,3424,2840,490,94);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('09-MAR-09','DD-MON-RR HH.MI.SSXFF AM'),17235.52,17145.58,3897.42,0,3504,2928,421,155);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('16-MAR-09','DD-MON-RR HH.MI.SSXFF AM'),15989.27,15989.27,3372.95,0,3728,3051,369,308);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('23-MAR-09','DD-MON-RR HH.MI.SSXFF AM'),19067.69,18960.41,4152.6,0,4048,3293,442,313);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('30-MAR-09','DD-MON-RR HH.MI.SSXFF AM'),18717.99,18717.99,3923.69,0,4408,3219,593,596);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('06-APR-09','DD-MON-RR HH.MI.SSXFF AM'),17335.16,17335.16,3769.08,0,3928,2997,514,417);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('13-APR-09','DD-MON-RR HH.MI.SSXFF AM'),18967.39,18967.39,4157.76,0,4144,2991,527,626);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('20-APR-09','DD-MON-RR HH.MI.SSXFF AM'),23090.88,23090.88,4427.96,0,5544,4493,560,491);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('27-APR-09','DD-MON-RR HH.MI.SSXFF AM'),24197.98,24132.99,4248.66,0,6680,5190,606,884);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('04-MAY-09','DD-MON-RR HH.MI.SSXFF AM'),20202.21,20137.22,3714.68,0,7052,6170,422,460);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('11-MAY-09','DD-MON-RR HH.MI.SSXFF AM'),18514.48,18514.48,3266.06,0,5508,4178,571,759);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('18-MAY-09','DD-MON-RR HH.MI.SSXFF AM'),18678.68,18678.68,3814.07,0,5824,4345,633,846);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('25-MAY-09','DD-MON-RR HH.MI.SSXFF AM'),17937.18,17937.18,3051.52,0,4844,4986,529,-671);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('01-JUN-09','DD-MON-RR HH.MI.SSXFF AM'),17445.75,17445.75,3079.91,0,5028,4810,656,-438);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('08-JUN-09','DD-MON-RR HH.MI.SSXFF AM'),17327.88,17327.88,3263.29,0,6112,4674,672,766);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('15-JUN-09','DD-MON-RR HH.MI.SSXFF AM'),17241.72,16937.33,3328.27,0,5792,4490,567,735);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('22-JUN-09','DD-MON-RR HH.MI.SSXFF AM'),16625.83,16625.83,3485.18,0,5408,4319,761,328);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('29-JUN-09','DD-MON-RR HH.MI.SSXFF AM'),17002.84,17002.84,3091.09,0,5664,4369,544,751);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('06-JUL-09','DD-MON-RR HH.MI.SSXFF AM'),16339.19,16274.2,3075.3,0,4784,3440,697,647);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('13-JUL-09','DD-MON-RR HH.MI.SSXFF AM'),17165.12,16885.14,3458.03,0,4320,3296,640,384);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('20-JUL-09','DD-MON-RR HH.MI.SSXFF AM'),17029.77,16899.79,3198.91,0,4448,3449,645,354);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('27-JUL-09','DD-MON-RR HH.MI.SSXFF AM'),16596.89,16596.89,3015.54,0,4624,3288,665,671);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('03-AUG-09','DD-MON-RR HH.MI.SSXFF AM'),16468.58,16468.58,2981.35,0,2224,3495,564,-1835);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('10-AUG-09','DD-MON-RR HH.MI.SSXFF AM'),18625.48,18550.5,3524.44,0,4856,3482,578,796);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('17-AUG-09','DD-MON-RR HH.MI.SSXFF AM'),24538.54,24323.55,5580.71,0,5260,3771,608,881);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('24-AUG-09','DD-MON-RR HH.MI.SSXFF AM'),18081.37,18081.37,3533.45,0,5980,3080,553,2347);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('31-AUG-09','DD-MON-RR HH.MI.SSXFF AM'),17183.25,17183.25,3487.12,0,2544,3262,615,-1333);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('07-SEP-09','DD-MON-RR HH.MI.SSXFF AM'),17688.41,17575.29,3424.17,0,4800,3480,591,729);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('14-SEP-09','DD-MON-RR HH.MI.SSXFF AM'),18211.29,18211.29,3806.32,0,3968,3104,527,337);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('21-SEP-09','DD-MON-RR HH.MI.SSXFF AM'),16809.21,16744.22,3014.61,0,4128,3124,710,294);
    SELECT HOT_DOG_STAND_ID
    , DECODE(TRUNC(week_date , 'iw') ,
             to_date('24-AUG-09' , 'dd-mon-rr') , 1 ,
             to_date('24-AUG-09' , 'dd-mon-rr') + 7 , 2 ,
             to_date('24-AUG-09' , 'dd-mon-rr') + 14 , 3 ,
             to_date('24-AUG-09' , 'dd-mon-rr') + 21 , 4 ,
             to_date('24-AUG-09' , 'dd-mon-rr') + 28 , 5 , 0) AS week_nbr
    , SUM(NET_SALES2)                                                                                                                                                                                                                                                     AS net_sales2
    , SUM(BUNS24434 ) BUNS24434
    , SUM(PICKELS_AW38) PICKELS_AW38
    , SUM(MUSTARD_TB56) MUSTARD_TB56
    , SUM(CHICKENHEADS33) CHICKENHEADS33
    , SUM(PIECES_SOLD34) PIECES_SOLD34
    , SUM(SCRAPS35) SCRAPS35
    , SUM(PIECES_UNACCOUNTED) * - 1 PIECES_UNACCOUNTED
       /*--== Head average  net_sales / chickenusage*/
    , CASE
          WHEN NVL( SUM(ChickenHeads33) / 8 , 0) = 0 THEN 0
          ELSE ROUND(SUM(net_sales2) / ( SUM(ChickenHeads33) / 8 ) , 2)
       END AS Head_average
       /*--=== Efficiency =   (ChickenUsage  - scrappedDiv8 - unaccountedDiv8) / ChickenUsage)  * 100*/
    , CASE
          WHEN NVL(SUM(ChickenHeads33) / 8 , 0) = 0 THEN 0
          ELSE ROUND((((SUM(ChickenHeads33) / 8 ) - ( SUM(scraps35) / 8 ) - (SUM(pieces_unaccounted) / 8 )) / (SUM(ChickenHeads33) / 8 )) * 100 , 2)
       END AS efficiency
    FROM period_data per
    WHERE week_DATE BETWEEN TRUNC(TO_DATE( '24-AUG-09' , 'DD-MON-YY') , 'IY') AND TRUNC(TO_DATE( '24-AUG-09' , 'DD-MON-YY') , 'IW') + 6 + 7 * 4
    GROUP BY hot_dog_stand_id
    , DECODE(TRUNC(week_date , 'iw') ,
          to_date('24-AUG-09' , 'dd-mon-rr') , 1 ,
          to_date('24-AUG-09' , 'dd-mon-rr') + 7 , 2 ,
          to_date('24-AUG-09' , 'dd-mon-rr') + 14 , 3 ,
          to_date('24-AUG-09' , 'dd-mon-rr') + 21 , 4 ,
          to_date('24-AUG-09' , 'dd-mon-rr') + 28 , 5 ,
          0)
    ORDER BY DECODE(TRUNC(week_date , 'iw') , to_date('24-AUG-09' , 'dd-mon-rr') , 1 , to_date('24-AUG-09' , 'dd-mon-rr') + 7 , 2 , to_date('24-AUG-09' , 'dd-mon-rr') + 14 , 3 , to_date('24-AUG-09' , 'dd-mon-rr') + 21 , 4 , to_date('24-AUG-09' , 'dd-mon-rr') + 28 , 5 , 0);The following was the successful solution: see: Need help getting YTD total
    VARIABLE   start_date     VARCHAR2 (11);
    EXEC         :start_date  := '24-AUG-2009';
         SELECT  HOT_DOG_STAND_ID
         ,      NVL (CASE
                   WHEN  week_date >= TO_DATE( :start_date, 'DD-MON-YYYY')
                   AND   week_date <  TO_DATE( :start_date, 'DD-MON-YYYY') + 35
                   THEN  1 + FLOOR ( (week_date - TO_DATE( :start_date, 'DD-MON-YYYY'))
                                             / 7
                   ELSE  0
                      END
                 , 7
                 )          AS week_nbr
    , SUM(NET_SALES2)                                                                                                                                                                                                                                                     AS net_sales2
    , SUM(BUNS24434 ) BUNS24434
    , SUM(PICKELS_AW38) PICKELS_AW38
    , SUM(MUSTARD_TB56) MUSTARD_TB56
    , SUM(CHICKENHEADS33) CHICKENHEADS33
    , SUM(PIECES_SOLD34) PIECES_SOLD34
    , SUM(SCRAPS35) SCRAPS35
    , SUM(PIECES_UNACCOUNTED) * - 1 PIECES_UNACCOUNTED
       /*--== Head average  net_sales / chickenusage*/
    , CASE
          WHEN NVL( SUM(ChickenHeads33) / 8 , 0) = 0 THEN 0
          ELSE ROUND(SUM(net_sales2) / ( SUM(ChickenHeads33) / 8 ) , 2)
       END AS Head_average
       /*--=== Efficiency =   (ChickenUsage  - scrappedDiv8 - unaccountedDiv8) / ChickenUsage)  * 100*/
    , CASE
          WHEN NVL(SUM(ChickenHeads33) / 8 , 0) = 0 THEN 0
          ELSE ROUND((((SUM(ChickenHeads33) / 8 ) - ( SUM(scraps35) / 8 ) - (SUM(pieces_unaccounted) / 8 )) / (SUM(ChickenHeads33) / 8 )) * 100 , 2)
       END AS efficiency
    FROM period_data per
    WHERE week_DATE BETWEEN TRUNC(TO_DATE( '24-AUG-09' , 'DD-MON-YY') , 'IY') AND TRUNC(TO_DATE( '24-AUG-09' , 'DD-MON-YY') , 'IW') + 6 + 7 * 4
    GROUP BY  hot_dog_stand_id
    ,           ROLLUP (
                 CASE
                   WHEN  week_date >= TO_DATE( :start_date, 'DD-MON-YYYY')
                   AND   week_date <  TO_DATE( :start_date, 'DD-MON-YYYY') + 35
                   THEN  1 + FLOOR ( (week_date - TO_DATE( :start_date, 'DD-MON-YYYY'))
                                             / 7
                   ELSE  0
                 END          -- week_nbr
    ORDER BY  week_nbr
    ;Thanks in advance .

    Frank Kulash wrote:
    Hi,
    There's probably a way to get both the year-to-date and the period_to_date totals using ROLLUP, but I don't know what that is.I replaced your WITH statement with
    --== ABBREVS: beginning-of-week, period-week-nbr, beginning-of-period, beginning-of-period-last-year
    with report_dates as
    select '24-AUG-09' gamedate, '239' week_nbr, '24-AUG-09' bow, '25-AUG-08' bow_ly, 9 per_nbr, 1 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '25-AUG-09' gamedate, '240' week_nbr, '24-AUG-09' bow, '25-AUG-08' bow_ly, 9 per_nbr, 1 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '26-AUG-09' gamedate, '241' week_nbr, '24-AUG-09' bow, '25-AUG-08' bow_ly, 9 per_nbr, 1 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '27-AUG-09' gamedate, '242' week_nbr, '24-AUG-09' bow, '25-AUG-08' bow_ly, 9 per_nbr, 1 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '28-AUG-09' gamedate, '243' week_nbr, '24-AUG-09' bow, '25-AUG-08' bow_ly, 9 per_nbr, 1 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '29-AUG-09' gamedate, '244' week_nbr, '24-AUG-09' bow, '25-AUG-08' bow_ly, 9 per_nbr, 1 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '30-AUG-09' gamedate, '245' week_nbr, '24-AUG-09' bow, '25-AUG-08' bow_ly, 9 per_nbr, 1 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '31-AUG-09' gamedate, '246' week_nbr, '31-AUG-09' bow, '01-SEP-08' bow_ly, 9 per_nbr,  2 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '01-SEP-09' gamedate, '247' week_nbr, '31-AUG-09' bow, '01-SEP-08' bow_ly, 9 per_nbr, 2 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '02-SEP-09' gamedate, '248' week_nbr, '31-AUG-09' bow, '01-SEP-08' bow_ly, 9 per_nbr, 2 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '03-SEP-09' gamedate, '249' week_nbr, '31-AUG-09' bow, '01-SEP-08' bow_ly, 9 per_nbr, 2 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '04-SEP-09' gamedate, '250' week_nbr, '31-AUG-09' bow, '01-SEP-08' bow_ly, 9 per_nbr, 2 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '05-SEP-09' gamedate, '251' week_nbr, '31-AUG-09' bow, '01-SEP-08' bow_ly, 9 per_nbr, 2 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '06-SEP-09' gamedate, '252' week_nbr, '31-AUG-09' bow, '01-SEP-08' bow_ly, 9 per_nbr, 2 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '07-SEP-09' gamedate, '253' week_nbr, '07-SEP-09' bow, '08-SEP-08' bow_ly, 9 per_nbr, 3 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '08-SEP-09' gamedate, '254' week_nbr, '07-SEP-09' bow, '08-SEP-08' bow_ly, 9 per_nbr, 3 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '09-SEP-09' gamedate, '255' week_nbr, '07-SEP-09' bow, '08-SEP-08' bow_ly, 9 per_nbr, 3 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '10-SEP-09' gamedate, '256' week_nbr, '07-SEP-09' bow, '08-SEP-08' bow_ly, 9 per_nbr, 3 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '11-SEP-09' gamedate, '257' week_nbr, '07-SEP-09' bow, '08-SEP-08' bow_ly, 9 per_nbr, 3 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '12-SEP-09' gamedate, '258' week_nbr, '07-SEP-09' bow, '08-SEP-08' bow_ly, 9 per_nbr, 3 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '13-SEP-09' gamedate, '259' week_nbr, '07-SEP-09' bow, '08-SEP-08' bow_ly, 9 per_nbr, 3 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '14-SEP-09' gamedate, '260' week_nbr, '14-SEP-09' bow, '15-SEP-08' bow_ly, 9 per_nbr, 4 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '15-SEP-09' gamedate, '261' week_nbr, '14-SEP-09' bow, '15-SEP-08' bow_ly, 9 per_nbr, 4 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '16-SEP-09' gamedate, '262' week_nbr, '14-SEP-09' bow, '15-SEP-08' bow_ly, 9 per_nbr, 4 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '17-SEP-09' gamedate, '263' week_nbr, '14-SEP-09' bow, '15-SEP-08' bow_ly, 9 per_nbr, 4 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '18-SEP-09' gamedate, '264' week_nbr, '14-SEP-09' bow, '15-SEP-08' bow_ly, 9 per_nbr, 4 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '19-SEP-09' gamedate, '265' week_nbr, '14-SEP-09' bow, '15-SEP-08' bow_ly, 9 per_nbr, 4 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '20-SEP-09' gamedate, '266' week_nbr, '14-SEP-09' bow, '15-SEP-08' bow_ly, 9 per_nbr, 4 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '21-SEP-09' gamedate, '267' week_nbr, '21-SEP-09' bow, '22-SEP-08' bow_ly, 9 per_nbr, 5 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '22-SEP-09' gamedate, '268' week_nbr, '21-SEP-09' bow, '22-SEP-08' bow_ly, 9 per_nbr, 5 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '23-SEP-09' gamedate, '269' week_nbr, '21-SEP-09' bow, '22-SEP-08' bow_ly, 9 per_nbr, 5 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '24-SEP-09' gamedate, '270' week_nbr, '21-SEP-09' bow, '22-SEP-08' bow_ly, 9 per_nbr , 5 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '25-SEP-09' gamedate, '271' week_nbr, '21-SEP-09' bow, '22-SEP-08' bow_ly, 9 per_nbr, 5 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '26-SEP-09' gamedate, '272' week_nbr, '21-SEP-09' bow, '22-SEP-08' bow_ly, 9 per_nbr, 5 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '27-SEP-09' gamedate, '273' week_nbr, '21-SEP-09' bow, '22-SEP-08' bow_ly, 9 per_nbr, 5 per_week_nbr, '24-AUG-09' bop, '25-AUG-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                   
    select '28-SEP-09' gamedate, '274' week_nbr, '28-SEP-09' bow, '29-SEP-08' bow_ly, 10 per_nbr,  1 per_week_nbr, '28-SEP-09' bop, '29-SEP-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                  
    select '29-SEP-09' gamedate, '275' week_nbr, '28-SEP-09' bow, '29-SEP-08' bow_ly, 10 per_nbr,  1 per_week_nbr, '28-SEP-09' bop, '29-SEP-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                  
    select '30-SEP-09' gamedate, '276' week_nbr, '28-SEP-09' bow, '29-SEP-08' bow_ly, 10 per_nbr, 1 per_week_nbr, '28-SEP-09' bop, '29-SEP-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual union all                                                                                                                  
    select '01-OCT-09' gamedate, '277' week_nbr, '28-SEP-09' bow, '29-SEP-08' bow_ly, 10 per_nbr, 1 per_week_nbr, '28-SEP-09' bop, '29-SEP-08' bop_ly, '29-DEC-08' boy, '29-DEC-07' boy_ly from dual                                                                                                               
    )which allowed me to substitute (see the func DDL below):
    ,  nvl( case
                  when week_date < dates.bop then 0
                  else fnc_get_per_week_nbr(week_date)
                end
            , 7)  as week_nbrThis is where i got stuck but I'm sure I was on right track
    with report_dates as
    --=== INSERT WITH CLAUSE FROM ABOVE ===---                                                             
    SELECT  HOT_DOG_STAND_ID
             --== when week_date < beginning of period then week nbr = 0 to representing beginning of year to end of previous period
           ,  nvl( case
                  when week_date < dates.bop then 0
                  else fnc_get_per_week_nbr(week_date)
                end
            , 7)  as week_nbr
    , SUM(NET_SALES2)   NET_SALES2                                                                                                                                                                                                                                                  AS net_sales2
    , SUM(BUNS24434 ) BUNS24434
    , SUM(PICKELS_AW38) PICKELS_AW38
    , max(sum(net_sales2))  over partition by(  ??? where week_nbr in (1,2,3,4,5) net_sales2_ptd
    , max(sum(BUNS24434))  over partition by(  ??? where week_nbr in (1,2,3,4,5) BUNS24434_ptd
    , max(sum(PICKELS_AW38))  over partition by(  ??? where week_nbr in (1,2,3,4,5) PICKELS_AW38_ptd
    FROM period_data per
    inner join report_dates dates on dates.game_date = TO_DATE( '26-AUG-09' , 'DD-MON-YY')
    WHERE week_DATE BETWEEN dates.boy AND to_date(dates.bow, 'dd-mon-yy') + 6
    GROUP BY  hot_dog_stand_id
    ,    ROLLUP (
                    case
                  when week_date < dates.bop then 0
                  else fnc_get_per_week_nbr(week_date)
                end
    ORDER BY  week_nbr
    ;As a footnote, in my live database, reports_tables is a table, so I cleaned up main SELECT with the referenced function:
    create or replace FUNCTION fnc_get_per_week_nbr(dte IN date)
    RETURN number IS
    out_week_nbr  number;
    BEGIN
    --== ABBREVS: beginning-of-week, period-week-nbr, beginning-of-period, beginning-of-period-last-year
    with report_dates as
                ---== Replace with Select statements to have sample data for func ==--                                                                                                         
    select per_week_nbr into out_week_nbr from report_dates where game_date =  dte;
         return out_week_nbr;
    END fnc_get_per_week_nbr;
    Without the correct desired results, I can't be sure if this is right.
    Your results were correct, totals and all. Thank you.
    There was a lot of unnecessary dividing by 8 going on.
    x / 8 = 0 if and only if x = 0, so there's no need to divide by 8 when testing for division by 0.
    (a/8) / (b/8) = a / b, so there's no need to divide by 8 at all when computing efficiency.
    thanks I had missed that.

  • Finance Report PTD and YTD calculations

    Hello All,
    I have a Report using the SSAS as Data-source.
    It is a finance report and I need to calculate PTD and YTD amounts.
    PTD:
    sum the amount for all of the years till a selected Fiscal Period(Parameter)
    Example: If The Cube have data for 2012, 2013 ,2014 and I have selected NOV-14 as my Fiscal Period , It should sum up the data for all the years including 2014 till Nov-14.
    YTD: should calculate the data for a Year till selected report period. Fiscal Period is not date data type.
    Please suggest.
    Best Regards,
    Pragati

    Hi Pragati,
    According to your description, you created a SQL Server Reporting Services report using SQL Server Analysis Services cube as data source, now what you want is calculate PTD and YTD amounts, right?
    In SSAS, we can use Ytd function to your requirement. It returns a set of sibling members from the same level as a given member, starting with the first sibling and ending with the given member, as constrained by the Year level in the Time dimension. Here is
    the sample query.
    WITH MEMBER [Date].[Calendar].[First8MonthsCY2003] AS
    Aggregate(
    YTD([Date].[Calendar].[Month].[August 2003])
    SELECT
    [Date].[Calendar].[First8MonthsCY2003] ON COLUMNS,
    [Product].[Category].Children ON ROWS
    FROM
    [Adventure Works]
    WHERE
    [Measures].[Order Quantity]
    Regards,
    Charlie Liao
    TechNet Community Support

  • Use of YTD versus PTD time variable

    All,
    Are there any reasons to move to YTD or stick with PTD from a system perspective? One reason to stick with PTD may be to comply with a regulated (calender year - December) and non-regulated (financial year - March) closing/reporting in the same application. BPC 7.0 provides the use of two time variables within the same application so that there may be no reason to use PTD. Is the use of YTD easier from a customisation and data migration perspective?
    Thank you for your advise.
    Marc

    All,
    Are there any reasons to move to YTD or stick with PTD from a system perspective? One reason to stick with PTD may be to comply with a regulated (calender year - December) and non-regulated (financial year - March) closing/reporting in the same application. BPC 7.0 provides the use of two time variables within the same application so that there may be no reason to use PTD. Is the use of YTD easier from a customisation and data migration perspective?
    Thank you for your advise.
    Marc

  • Need help getting YTD total

    I've got a period to date report with following columns:
    week1 tots, week2 tots, week3 tots, week4 tots, week5 tot, period-to-date tots, year-to-date tots
    I have a SELECT statement which totals data for the entire year and separates current period totals
    by grouping on the week_nbr . Any date between beginning of year and the end of the previous period will be week 0
    The Select statement retursn 6 rows: 1 for each week in period and one with week_nbr = 0 which represents the totals from the beginning of year
    to the end of the previous period.
    the select statement returns the data correctly . I need help getting the YTD total for (weeks 1 - 5) + (totals for week 0) for each column.
    This means that I will have a 7th record containing the YTD totals. ( I am not concerned with the PTD totals)
    I tried sum by partition but complex decode statement gave me problems.
      CREATE TABLE PERIOD_DATA
       (     "HOT_DOG_STAND_ID" NUMBER NOT NULL ENABLE,
         "WEEK_DATE" DATE,
         "NET_SALES2" NUMBER,
         "BUNS24434" NUMBER,
         "PICKELS_AW38" NUMBER,
         "MUSTARD_TB56" NUMBER,
         "CHICKENHEADS33" NUMBER,
         "PIECES_SOLD34" NUMBER,
         "SCRAPS35" NUMBER,
         "PIECES_UNACCOUNTED" NUMBER
    REM INSERTING into PERIOD_DATA
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('29-DEC-08','DD-MON-RR HH.MI.SSXFF AM'),14301.39,13951.26,3431.13,0,3680,2484,378,818);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('05-JAN-09','DD-MON-RR HH.MI.SSXFF AM'),14651.37,14651.37,3249.55,0,3200,2419,505,276);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('12-JAN-09','DD-MON-RR HH.MI.SSXFF AM'),14169.89,14169.89,2463.53,0,3136,2080,474,582);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('19-JAN-09','DD-MON-RR HH.MI.SSXFF AM'),15864.46,15864.46,3245.49,0,3472,2764,475,233);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('26-JAN-09','DD-MON-RR HH.MI.SSXFF AM'),15961.2,15916.23,3395.51,0,3648,2838,392,418);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('02-FEB-09','DD-MON-RR HH.MI.SSXFF AM'),19066.4,19066.4,4165.07,0,4336,3682,333,321);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('09-FEB-09','DD-MON-RR HH.MI.SSXFF AM'),18415.74,18415.74,4024.74,0,4032,3365,482,185);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('16-FEB-09','DD-MON-RR HH.MI.SSXFF AM'),18014,17849,3486.33,0,3840,3238,374,228);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('23-FEB-09','DD-MON-RR HH.MI.SSXFF AM'),18671.09,18626.12,3729.42,0,3888,2970,353,565);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('02-MAR-09','DD-MON-RR HH.MI.SSXFF AM'),17636,17636,3815,0,3424,2840,490,94);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('09-MAR-09','DD-MON-RR HH.MI.SSXFF AM'),17235.52,17145.58,3897.42,0,3504,2928,421,155);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('16-MAR-09','DD-MON-RR HH.MI.SSXFF AM'),15989.27,15989.27,3372.95,0,3728,3051,369,308);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('23-MAR-09','DD-MON-RR HH.MI.SSXFF AM'),19067.69,18960.41,4152.6,0,4048,3293,442,313);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('30-MAR-09','DD-MON-RR HH.MI.SSXFF AM'),18717.99,18717.99,3923.69,0,4408,3219,593,596);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('06-APR-09','DD-MON-RR HH.MI.SSXFF AM'),17335.16,17335.16,3769.08,0,3928,2997,514,417);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('13-APR-09','DD-MON-RR HH.MI.SSXFF AM'),18967.39,18967.39,4157.76,0,4144,2991,527,626);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('20-APR-09','DD-MON-RR HH.MI.SSXFF AM'),23090.88,23090.88,4427.96,0,5544,4493,560,491);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('27-APR-09','DD-MON-RR HH.MI.SSXFF AM'),24197.98,24132.99,4248.66,0,6680,5190,606,884);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('04-MAY-09','DD-MON-RR HH.MI.SSXFF AM'),20202.21,20137.22,3714.68,0,7052,6170,422,460);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('11-MAY-09','DD-MON-RR HH.MI.SSXFF AM'),18514.48,18514.48,3266.06,0,5508,4178,571,759);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('18-MAY-09','DD-MON-RR HH.MI.SSXFF AM'),18678.68,18678.68,3814.07,0,5824,4345,633,846);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('25-MAY-09','DD-MON-RR HH.MI.SSXFF AM'),17937.18,17937.18,3051.52,0,4844,4986,529,-671);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('01-JUN-09','DD-MON-RR HH.MI.SSXFF AM'),17445.75,17445.75,3079.91,0,5028,4810,656,-438);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('08-JUN-09','DD-MON-RR HH.MI.SSXFF AM'),17327.88,17327.88,3263.29,0,6112,4674,672,766);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('15-JUN-09','DD-MON-RR HH.MI.SSXFF AM'),17241.72,16937.33,3328.27,0,5792,4490,567,735);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('22-JUN-09','DD-MON-RR HH.MI.SSXFF AM'),16625.83,16625.83,3485.18,0,5408,4319,761,328);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('29-JUN-09','DD-MON-RR HH.MI.SSXFF AM'),17002.84,17002.84,3091.09,0,5664,4369,544,751);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('06-JUL-09','DD-MON-RR HH.MI.SSXFF AM'),16339.19,16274.2,3075.3,0,4784,3440,697,647);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('13-JUL-09','DD-MON-RR HH.MI.SSXFF AM'),17165.12,16885.14,3458.03,0,4320,3296,640,384);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('20-JUL-09','DD-MON-RR HH.MI.SSXFF AM'),17029.77,16899.79,3198.91,0,4448,3449,645,354);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('27-JUL-09','DD-MON-RR HH.MI.SSXFF AM'),16596.89,16596.89,3015.54,0,4624,3288,665,671);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('03-AUG-09','DD-MON-RR HH.MI.SSXFF AM'),16468.58,16468.58,2981.35,0,2224,3495,564,-1835);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('10-AUG-09','DD-MON-RR HH.MI.SSXFF AM'),18625.48,18550.5,3524.44,0,4856,3482,578,796);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('17-AUG-09','DD-MON-RR HH.MI.SSXFF AM'),24538.54,24323.55,5580.71,0,5260,3771,608,881);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('24-AUG-09','DD-MON-RR HH.MI.SSXFF AM'),18081.37,18081.37,3533.45,0,5980,3080,553,2347);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('31-AUG-09','DD-MON-RR HH.MI.SSXFF AM'),17183.25,17183.25,3487.12,0,2544,3262,615,-1333);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('07-SEP-09','DD-MON-RR HH.MI.SSXFF AM'),17688.41,17575.29,3424.17,0,4800,3480,591,729);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('14-SEP-09','DD-MON-RR HH.MI.SSXFF AM'),18211.29,18211.29,3806.32,0,3968,3104,527,337);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('21-SEP-09','DD-MON-RR HH.MI.SSXFF AM'),16809.21,16744.22,3014.61,0,4128,3124,710,294);
    SELECT HOT_DOG_STAND_ID
    , DECODE(TRUNC(week_date , 'iw') ,
             to_date('24-AUG-09' , 'dd-mon-rr') , 1 ,
             to_date('24-AUG-09' , 'dd-mon-rr') + 7 , 2 ,
             to_date('24-AUG-09' , 'dd-mon-rr') + 14 , 3 ,
             to_date('24-AUG-09' , 'dd-mon-rr') + 21 , 4 ,
             to_date('24-AUG-09' , 'dd-mon-rr') + 28 , 5 , 0) AS week_nbr
    , SUM(NET_SALES2)                                                                                                                                                                                                                                                     AS net_sales2
    , SUM(BUNS24434 ) BUNS24434
    , SUM(PICKELS_AW38) PICKELS_AW38
    , SUM(MUSTARD_TB56) MUSTARD_TB56
    , SUM(CHICKENHEADS33) CHICKENHEADS33
    , SUM(PIECES_SOLD34) PIECES_SOLD34
    , SUM(SCRAPS35) SCRAPS35
    , SUM(PIECES_UNACCOUNTED) * - 1 PIECES_UNACCOUNTED
       /*--== Head average  net_sales / chickenusage*/
    , CASE
          WHEN NVL( SUM(ChickenHeads33) / 8 , 0) = 0 THEN 0
          ELSE ROUND(SUM(net_sales2) / ( SUM(ChickenHeads33) / 8 ) , 2)
       END AS Head_average
       /*--=== Efficiency =   (ChickenUsage  - scrappedDiv8 - unaccountedDiv8) / ChickenUsage)  * 100*/
    , CASE
          WHEN NVL(SUM(ChickenHeads33) / 8 , 0) = 0 THEN 0
          ELSE ROUND((((SUM(ChickenHeads33) / 8 ) - ( SUM(scraps35) / 8 ) - (SUM(pieces_unaccounted) / 8 )) / (SUM(ChickenHeads33) / 8 )) * 100 , 2)
       END AS efficiency
    FROM period_data per
    WHERE week_DATE BETWEEN TRUNC(TO_DATE( '24-AUG-09' , 'DD-MON-YY') , 'IY') AND TRUNC(TO_DATE( '24-AUG-09' , 'DD-MON-YY') , 'IW') + 6 + 7 * 4
    GROUP BY hot_dog_stand_id
    , DECODE(TRUNC(week_date , 'iw') ,
          to_date('24-AUG-09' , 'dd-mon-rr') , 1 ,
          to_date('24-AUG-09' , 'dd-mon-rr') + 7 , 2 ,
          to_date('24-AUG-09' , 'dd-mon-rr') + 14 , 3 ,
          to_date('24-AUG-09' , 'dd-mon-rr') + 21 , 4 ,
          to_date('24-AUG-09' , 'dd-mon-rr') + 28 , 5 ,
          0)
    ORDER BY DECODE(TRUNC(week_date , 'iw') , to_date('24-AUG-09' , 'dd-mon-rr') , 1 , to_date('24-AUG-09' , 'dd-mon-rr') + 7 , 2 , to_date('24-AUG-09' , 'dd-mon-rr') + 14 , 3 , to_date('24-AUG-09' , 'dd-mon-rr') + 21 , 4 , to_date('24-AUG-09' , 'dd-mon-rr') + 28 , 5 , 0);The expected results will be:
    HOT_DOG_STAND_ID       WEEK_NBR               NET_SALES2             BUNS24434              PICKELS_AW38           MUSTARD_TB56           CHICKENHEADS33         PIECES_SOLD34          SCRAPS35               PIECES_UNACCOUNTED     HEAD_AVERAGE           EFFICIENCY            
    141                    7                      697067.09              694887.4               139149.91              0                      175808                 139454                 21036                  15318                  31.72                  79.32                  You can get these dame results by running endpot-to-endpoint query:
    SELECT  HOT_DOG_STAND_ID
         , max(7) as week_nbr
         ,sum(NET_SALES2)      net_sales2
          ,sum(BUNS24434 )        BUNS24434
          ,sum(PICKELS_AW38)      PICKELS_AW38
          ,sum(MUSTARD_TB56)     MUSTARD_TB56
          ,sum(CHICKENHEADS33)   CHICKENHEADS33
          ,sum(PIECES_SOLD34)    PIECES_SOLD34
          ,sum(SCRAPS35)         SCRAPS35
          ,sum(PIECES_UNACCOUNTED)   PIECES_UNACCOUNTED
        ---===== Copied code from outer query
              --==  net_sales / chickenusage 
                      ,   CASE
                             WHEN NVL( sum(ChickenHeads33) / 8    ,0)  = 0 then 0
                             ELSE ROUND(sum(net_sales2)/   ( sum(ChickenHeads33) / 8    ) , 2)
                          END as Head_average
                        --=== Efficiency =   (ChickenUsage  - scrappedDiv8 - unaccountedDiv8) / ChickenUsage)  * 100
                        ,   CASE
                                  WHEN NVL(sum(ChickenHeads33) / 8    ,0)  = 0 then 0
                                  ELSE   ROUND((((sum(ChickenHeads33) / 8 )  - ( sum(scraps35) / 8 ) - (sum(pieces_unaccounted) / 8 )) / (sum(ChickenHeads33) / 8 )) * 100, 2)
                          END as efficiency  
    from period_data
    WHERE week_DATE BETWEEN TRUNC(TO_DATE( '24-AUG-09' ,'DD-MON-YY'), 'IY') AND TO_DATE( '27-sep-09' ,'DD-MON-YY')
    group by hot_dog_stand_id;Thanks In Advance

    Hi,
    Welcome to the forum!
    Thanks for posting the CREATE TABLE and INSERT statements; that's very helpful. You could teach something to some people who have been using this forum for years (except that nobody can teach them).
    user12335325 wrote:
    The expected results will be:
    HOT_DOG_STAND_ID       WEEK_NBR               NET_SALES2             BUNS24434              PICKELS_AW38           MUSTARD_TB56           CHICKENHEADS33         PIECES_SOLD34          SCRAPS35               PIECES_UNACCOUNTED     HEAD_AVERAGE           EFFICIENCY            
    141                    7                      697067.09              694887.4               139149.91              0                      175808                 139454                 21036                  15318                  31.72                  79.32                 
    Do you mean the expected results will include the row above, and that the results will be this row along with the 6 rows you're already getting? (If you wanted just that one row, I suppose you would just run your second query.)
    That sound like a job for ROLLUP.
    VARIABLE   start_date     VARCHAR2 (11);
    EXEC         :start_date  := '24-AUG-2009';
         SELECT  HOT_DOG_STAND_ID
         ,      NVL (CASE
                   WHEN  week_date >= TO_DATE( :start_date, 'DD-MON-YYYY')
                   AND   week_date <  TO_DATE( :start_date, 'DD-MON-YYYY') + 35
                   THEN  1 + FLOOR ( (week_date - TO_DATE( :start_date, 'DD-MON-YYYY'))
                                             / 7
                   ELSE  0
                      END
                 , 7
                 )          AS week_nbr
    , SUM(NET_SALES2)                                                                                                                                                                                                                                                     AS net_sales2
    , SUM(BUNS24434 ) BUNS24434
    , SUM(PICKELS_AW38) PICKELS_AW38
    , SUM(MUSTARD_TB56) MUSTARD_TB56
    , SUM(CHICKENHEADS33) CHICKENHEADS33
    , SUM(PIECES_SOLD34) PIECES_SOLD34
    , SUM(SCRAPS35) SCRAPS35
    , SUM(PIECES_UNACCOUNTED) * - 1 PIECES_UNACCOUNTED
       /*--== Head average  net_sales / chickenusage*/
    , CASE
          WHEN NVL( SUM(ChickenHeads33) / 8 , 0) = 0 THEN 0
          ELSE ROUND(SUM(net_sales2) / ( SUM(ChickenHeads33) / 8 ) , 2)
       END AS Head_average
       /*--=== Efficiency =   (ChickenUsage  - scrappedDiv8 - unaccountedDiv8) / ChickenUsage)  * 100*/
    , CASE
          WHEN NVL(SUM(ChickenHeads33) / 8 , 0) = 0 THEN 0
          ELSE ROUND((((SUM(ChickenHeads33) / 8 ) - ( SUM(scraps35) / 8 ) - (SUM(pieces_unaccounted) / 8 )) / (SUM(ChickenHeads33) / 8 )) * 100 , 2)
       END AS efficiency
    FROM period_data per
    WHERE week_DATE BETWEEN TRUNC(TO_DATE( '24-AUG-09' , 'DD-MON-YY') , 'IY') AND TRUNC(TO_DATE( '24-AUG-09' , 'DD-MON-YY') , 'IW') + 6 + 7 * 4
    GROUP BY  hot_dog_stand_id
    ,           ROLLUP (
                 CASE
                   WHEN  week_date >= TO_DATE( :start_date, 'DD-MON-YYYY')
                   AND   week_date <  TO_DATE( :start_date, 'DD-MON-YYYY') + 35
                   THEN  1 + FLOOR ( (week_date - TO_DATE( :start_date, 'DD-MON-YYYY'))
                                             / 7
                   ELSE  0
                 END          -- week_nbr
    ORDER BY  week_nbr
    ;Notice I simplified the computation of week_nbr.
    Some other people have asked questions about hot dog stands recently.
    I'm curious; is this from a course? If so, where? What is the textbook (if any)?
    Thanks.

  • Cannot send email from promail.ptd in iPad Air

    Help, I have deleted the accounts, rebooted the iPad &amp; nothing has worked. My gmail is working fine but these other two from ptd.net cannot send. And, when I try deleting emails, they flood back into the account.

    Hi,
    Check if you have the Accepted domain settings are correct.
    ECP->Mail Flow->Accepted Domains. Make sure that your default domain is the domain which is having the AD name (eg.domain.local)
    Regards from ExchangeOnline.in|Windows Administrator Area | Skype:[email protected]

  • FR : How to change from monthly to YTD or quarter data in the same report

    Hi,
    We have several basic reports with 12 month in columns with monthly figures. We would like to try to improve these reports with 2 options (and not creating new reports):
    - For each month, we would like to choose between monthly & year to date figures. (we do not have a view dimension with YTD member)
    - In our period dimension we also have quarter members. How to choose between displaying month or quarter with the prompts ? (ie without having to select each month one by one)
    Does it is possible to do this with FR without adding a new dimension for monthly or YTD data?
    thanks!
    Tipiak

    Hi Tipiak,
    In order to show YTD Actual figure for the selected month, I was doing something like that
    - Add a hidden col from Jan to Run Time period selected.
    - Add a visible formula col and add the formula showing the total of the hidden col.
    Your requirement seems more complex but you might meet some part as an initial step maybe...
    Regards,
    Ahmet

  • YTD, MTD, Prior Year, Prior Month calculations in SAP BW Universe

    I am finding the SAP BW based universe a totally different animal so far and my question comes from my inexperience in this domain.
    In a normal universe, one can use CASE Statement and Calendar or Time table to help do these calculations. Since BW based universes are based on a super BEx query, how are these calculations done in the universe? Are these calculations done in the BEx query itself?
    Are there any standards of what should be handled on the BEx side vs. what should be handled on the Universe side?
    Also, what's the syntax of a CASE statment or using Substring (or similar function) in a BW universe?
    Thanks!

    Hi,
    You can define calculated measures in OLAP universes using MDX language.
    To define a Calculated Measure, users must create manually new Measures in the Universe.
    Calculated Measures definitions are using MDX functions embedded in XML tags.
    In order to create calculated measures, users must to create pure MDX expression emclosed in XML tags: <EXPRESSION></EXPRESSION>
    In this new expression, we authorize to use any Designer function such as:
    u2022     @SELECT
    u2022     @PROMPT
    u2022     @VARIABLE
    The check integrity will validate the XML syntax and any of the Designer functions described above.
    No MDX parser is provided in this version of Universe Designer.
    This paragraph describes how to define calculated measures in MDX and using @Select and @Prompt functions.
    CASE statement is not supported in MDX but you can use IIF statement instead of.
    It is important to notice that the result of a calculated measure/member in SAP BW (using MDX) must be numeric due to a current limitation f the SAP MDX engine.
    Here is 2 samples of an MDX expression using YTD:
        <EXPRESSION>
    SUM(YTD(@Select(Key Figures\Billed Quantity
    </EXPRESSION>
        <EXPRESSION>
    SUM(YTD([Measures].[D3B1M57O3MN5499LF2X9UNHKA]))
    </EXPRESSION>
    Regards,
    Didier

Maybe you are looking for

  • CS5.5 hangs on file import

    I have been using PP for several versions and have never experienced any major issues until now.  At some point in the last few weeks (cannot link it to a recent PP update, but that may be the case) I have started having extreme problems when importi

  • Error occurred during HTTP communication

    I'm trying to launch ICWC from gui and here's the message that comes up in the web page : The runtime repository could not be interpreted An exception has occurredException Class CX_BSP_WD_HTTP_COMM_ERROR Text: Error occurred during HTTP communicatio

  • SPELL CHECKER

    As typing in a spell checker mode. Is it possible to have the "red underline" also make a sound. Example, at the same time as the red is displayed, sound a "tink" or other user selectable sound. This will alert the user to look at the screen and "del

  • 8i minimal install on web server

    Hello. I have to install Oracle 8i Enterprise Edition on our Web Server (NT 4.0 + IIS 4.0). Provided that: 1) this is my second experience with Oracle install 2) I don't want any development tool on this box, only those needed to manage a database an

  • BIBeans on WinNT - killer of previously working OLAP samples?

    I installed JDeveloper 9i RC and BiBeans RC. I applied all the latest OLAP patches and started working on BiBeans tutorial. I installed the demo database bibdemo schema and started creating OLAP connection required by Designer wizard. As other people