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.

Similar Messages

  • How to get Open Balance for the year and Total Ending Balance?

    For a given account, how to get Open Balance for the year (Cumulative Ending Balance) and Total Ending Balance (Cumulative Ending Balance)?
    Is there any function module available? or should I read from some tables? Please advice.

    Hello Paul,
    You could try calling one of the following BAPIs - see which one meets your requirement. They are documented well so shouldn't be a problem finding out the correct one for your requirements.
    BAPI_GL_GETGLACCBALANCE      
    BAPI_GL_GETGLACCCURRENTBALANCE
    BAPI_GL_ACC_GETBALANCE      
    BAPI_GL_ACC_GETCURRENTBALANCE
    BAPI_GL_ACC_GETPERIODBALANCES
    BAPI_COND_VAL_DECRE_BALANCES
    You might have to put in some of your own logic after the BAPI call to get what you want.
    Hope this helps,
    Cheers,
    Sougata.
    p.s. Also look at FM FAGL_GET_ACCOUNT_BALANCE
    Edited by: Sougata Chatterjee on May 7, 2008 11:47 AM

  • How to get the data for last 3rd business day and also include saturday and sunday if its a wednesday?

    Hi All,
    I have a simple query which is below:-
    Declare @reportdate date
    set @reportdate= (DATEADD(dd,-5,getdate()))
    select * from dbo.Table
    where date IN (@reportdate)
    I need this query to pull the data for the last 3rd business day .So lets say today is monday then i need the data for last week wednesday which is 3 business days back from monday, if today is a tuesday it would be for last thursday ( as 3 business days for
    tuesday would be thursday). But if today is wednesday then i need to be last 3rd business day which is last friday and i also need to get the data for saturday and sunday.
    Can someone please help me how cani change my filter to do this?
    Please let me know if i am still unclear.
    Thanks

    Hi SqlDev12,
    Based on my understanding on your requirement, you can reference the below sample.
    CREATE TABLE BusinessTable
    Bdate DATE,
    Wd VARCHAR(10)
    ;WITH Cte(DT,WD) AS
    SELECT CAST('20150401' AS DATE),DATENAME(WEEKDAY,CAST('20150401' AS DATE))
    UNION ALL
    SELECT DATEADD(DAY,1,DT),DATENAME(WEEKDAY,DATEADD(DAY,1,DT)) FROM Cte
    WHERE DT<GETDATE()
    INSERT INTO BusinessTable SELECT * FROM Cte
    SELECT * FROM BusinessTable
    SET DATEFIRST 7 -- Set Sunday as the first day of a week
    DECLARE @givenDay DATE ='20150415' --Wednesday
    SELECT * FROM BusinessTable
    WHERE Bdate BETWEEN
    --For Monday and Sunday, select last wednesday
    (CASE WHEN DATEPART(WEEKDAY,@givenDay) IN(1,2) THEN DATEADD(DAY,2,DATEADD(WEEK,DATEDIFF(WEEK,0,@givenDay)-1,0))
    --For Tuesday and Wednesday, last week's Thursday and Friday
    WHEN DATEPART(WEEKDAY,@givenDay) IN(3,4) THEN DATEADD(DAY,-5,@givenDay)
    --For Thursday and Friday, current week's Monday and Tuesday
    WHEN DATEPART(WEEKDAY,@givenDay) IN(5,6) THEN DATEADD(DAY,-3,@givenDay)
    --For Saturday, current week's Wednesday
    ELSE DATEADD(DAY,2,DATEADD(WEEK,DATEDIFF(WEEK,0,@givenDay),0)) END)
    AND
    (CASE WHEN DATEPART(WEEKDAY,@givenDay) IN(1,2) THEN DATEADD(DAY,2,DATEADD(WEEK,DATEDIFF(WEEK,0,@givenDay)-1,0))
    WHEN DATEPART(WEEKDAY,@givenDay) IN(3) THEN DATEADD(DAY,-5,@givenDay)
    WHEN DATEPART(WEEKDAY,@givenDay) IN(4) THEN DATEADD(DAY,-3,@givenDay)
    WHEN DATEPART(WEEKDAY,@givenDay) IN(5,6) THEN DATEADD(DAY,-3,@givenDay)
    ELSE DATEADD(DAY,2,DATEADD(WEEK,DATEDIFF(WEEK,0,@givenDay),0)) END)
    DROP TABLE BusinessTable
    If you have any feedback on our support, you can click
    here.
    Eric Zhang
    TechNet Community Support

  • Problem in Getting Count answer for the report in OBIEE 11g..

    Hi friends,
    I created a report in OBIEE 11g, but i'm not getting the correct answer as i expected...I'm getting answer in presentation services but the answer is wrong..
    I'll explain to you with an example report: Suppose in the report "NATIONALITY COUNT IN DEPARTMENT WISE" manner
    i dragged the Nationality column from per_all_people_f which is dim table and i dragged the column that i applied aggregation rule "count" for the column "nation count" from per_all_assignments_f which is fact table......If i viewed answers means i'm getting correct answer
    (i.e.) nation count per Nationality..........
    NATIONALITY<---------------------->NATION COUNT
    AUSTRALIA 40
    INDIA 20
    AFRICA 10
    USA 5
    The above is the answer I'm getting with out including the department column from hr_all_organization_units...........
    But since according to the report i need count in department wise manner, so for that along with nationality and nation count column i dragged department column from hr_all_organization_units which is dim table and also i hide that column as i dont want to view the department column in answers..........
    If i clicked answers, means then I'm not getting the nation count for the nationality......... I'm getting the answer 0 for each and every nationality, if i included the hided department column
    NATIONALITY<----------------->NATION COUNT
    AFRICA 0
    AUSTRALIA 0
    INDIA 0
    USA 0
    I'm getting answers like the above if i include the department dimension column which is in hided manner.........................
    What is wrong with it........Whether i made any logical mistake for the report.....If so guide me friends..........
    Cheers,
    Harry...........

    Hi,
    you said about writing query in DB.......whether U meant of trying checking the query in toad..or something else..........
    Since im giving only one join from dim to fact in the physical diagram........
    But more than one join exist between those dim and fact, but im giving only one join mainly the primary key column of the dimension table to the fact table....Whether i need to give all the joins that exist(even if it has 2 or 3 joins between those fact and dim) tables....
    If i give count distinct means it is giving count for every nation as 1....like i mentioned below
    NATIONALITY<----------------------------------------------------->NATION COUNT
    INDIA---------------------------------------------------------------------1
    AUS------------------------------------------------------------------------1
    CAN------------------------------------------------------------------------1
    Since you said to check about depts of the particular column....i couldn't able to understand about "depts" that you meant????
    Whether i made any logical mistake...........
    thanks,
    Harry...
    Edited by: HariPrasad on Oct 10, 2010 9:55 PM

  • How to get the same period last year value using Fiscal Calendar?

    Hi there,
    I am using DAX in a Tabular Model project but I am getting stuck trying to get the following:
    We are using a Fiscal Calendar (from 01 April to 31 March). 
    Previous Period Value
           Value
    2012
    April
    15
    May
    10
    Jun
    20
    2013
    April
    15
    30
    May
    10
    20
    Jun
    20
    25
    I have tried to use sameperiodlastyear but there is an error saying that this function cannot be used for non contiguous dates. DATEADD is given the same error...
    Could anyone help me getting the right measure expressions for [Previous Period Value]?
    Thanks and best regards,
    Joss

    Hi Joss,
    In SQL Server Analysis Services, we can can compare revenue with the hierarchy periods (year, month, day) by using the PARALLELPERIOD function, and now you want to compare with custom periods. (NOTE: We cannot compare it with the PARALLELPERIOD function
    since
    PARALLELPERIOD function returns a member from a prior period in the same relative position as a specified member. So if the first time span not equal to the second one (such as the first period is 3 days, and the second period is 2 month)).  Here
    is a sample query about PARALLELPERIOD function for your reference.
    with
    set Hotels as
    [Hotels].[Hotel ID].&[1015],
    [Hotels].[Hotel ID].&[5640],
    [Hotels].[Hotel ID].&[8800]
    set Period as [Arrival Date].[Date].[Month].&[2012]&[1]:[Arrival Date].[Date].[Month].&[2012]&[12]
    member [Arrival Date].[Date].[0] as sum({ Period })
    member [Total Amount N-1] as (PARALLELPERIOD([Arrival Date].[Date].[Year], 1, [Arrival Date].[Date].[Year].&[2012]), [Measures].[Total Amount])
    select
    [Measures].[Total Amount],
    [Measures].[Total Amount N-1]
    } on 0,
    nonemptycrossjoin
    Hotels,
    Hotels.[Hotel].children,
    *{[Arrival Date].[Date].[0]}
    } on 1
    from [Booking_Cube]
    Regards,
    Charlie Liao
    TechNet Community Support

  • How to get (database) connections for building an extension in 11g?

    Hi,
    I have built an extension for jdeveloer/sqldeveloper and I used the ConnectionManager Class to start my dockable.
    Having migrated from Jdev10g to 11g it looks like that the ConnectionManager class was removed, at least I'm
    not able to locate it anymore.
    I've provided the source code below, to show how I used to work with the class.
    String connectionNames[] = ConnectionManager.getInstance().getConnectionNames();
    DatabaseConnections.getInstance();
    ... Loop ...
    if (i >= connectionNames.length)
    break;
    String name = connectionNames;
    if (name.equals(dockableId))
    ... Start dockable...
    What is the supported way to work with connections in 11g?
    Best regards,
    Ingo

    Hi,
    thanks for the quick response. Seems that my extension project in Jdev 10g was messed up by putting the new sqldevloper.jar in the class path. I've migrated to Jdev11g and the missing class is found.
    Where I'm lost right now is the way to get a connection from the pool. Most of the classes that I used for that (oracle.jdeveloper.cm.dt.ConnectionNode, oracle.jdeveloper.cm.dt.DatabaseConnectionNode;)
    are not longer existing and it looks like there is a new way to achieve this in Jdev11g.
    Is there a documentation available somewhere, where the "new" strategy is explained?
    Best reagards,
    Ingo

  • Can any body tell me how to get a call for adobe interview for a flex developer post for 2.6 years??

    can any body tell me how to get a call for adobe interview for a flex developer post for 2.6 years??

    hi,
    there's some microsoft support to this issue. check here http://support.microsoft.com/kb/2008385 
    regards.
    From out of Nowhere

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

  • How to get the date for the first monday of each month

    Dear Members,
    How to get the date for the first monday of each month.
    I have written the following code
    SELECT decode (to_char(trunc(sysdate+30 ,'MM'),'DAY'),'MONDAY ',trunc(sysdate+30 ,'MM'),NEXT_DAY(trunc(sysdate+30 ,'MM'), 'MON')) FROM DUAL
    But it look bith complex.
    Abhishek
    Edited by: 9999999 on Mar 8, 2013 4:30 AM

    Use IW format - it will make solution NLS independent. And all you need is truncate 7<sup>th</sup> day of each month using IW:
    select  sysdate current_date,
            trunc(trunc(sysdate,'mm') + 6,'iw') first_monday_the_month
      from  dual
    CURRENT_D FIRST_MON
    08-MAR-13 04-MAR-13
    SQL> Below is list of first monday of the month for this year:
    with t as(
              select  add_months(date '2013-1-1',level-1) dt
                from  dual
                connect by level <= 12
    select  dt first_of_the_month,
            trunc(dt + 6,'iw') first_monday_the_month
      from  t
    FIRST_OF_ FIRST_MON
    01-JAN-13 07-JAN-13
    01-FEB-13 04-FEB-13
    01-MAR-13 04-MAR-13
    01-APR-13 01-APR-13
    01-MAY-13 06-MAY-13
    01-JUN-13 03-JUN-13
    01-JUL-13 01-JUL-13
    01-AUG-13 05-AUG-13
    01-SEP-13 02-SEP-13
    01-OCT-13 07-OCT-13
    01-NOV-13 04-NOV-13
    FIRST_OF_ FIRST_MON
    01-DEC-13 02-DEC-13
    12 rows selected.
    SQL> SY.

  • Qry:How to get different price for each price list (variable area) in order

    1-How to get different price for each price list (variable area) in order for sale. for the opportunity to display and select multiple prices.
    2- I add a location store from a table in line item and I want to see this area in order,.
    I 'm created 2 field location(item line and order), 1 table location
    I tried this for exemple : select $ [userfieldlocation.OITW]

    Thanks Suda for your answer,
    the Formatted Search for prices is OK, but for the Item locations in warehouse this is not so simple,     
    I must have several (at least 2) locations for the item in the Warehouse and a track of this location and search possibilities.
    read carefully and imagine how (Management warehouse locations)
    I added a user table '@Location' who linked to a user field 'U_Location in Item master data --> lnventory data  line and an ather user field 'U_Location' in sales order
    I met the value of location in the table (list of locations for any warehouse), I select the location of each item while receiving merchandise in the user field of inventory data line (Item M data) and this value appears in the sales order 'U_Location' user field ( only the location value in the default warehouse for this Item)
    or
    create an user field 'location' in Good receipt PO to fill it while receiving merchandise that appears in the sales order to give possibility to find/select the location of the item at this order and in Item master data
    I think we will use all these tables
    @LOCATION
    PDN1
    OITM
    OITW
    OWHS
    RDR1
    Juste a another question : where you found this and What is: ' 38.1.0 '
    Is it in document (System information):Item=38 Pane=1 ??
    Thanks,
    Ouchen

  • Materialstocks for last years

    hi guys,
    I have used the 2LIS_03_BX (Stock Initialization for Inventory Management  
    ) and 2LIS_03_BF (Goods Movements From Inventory Management). When I reviews my queries,
    the Goods Movements are ok.
    I have loaded the data into BW today as written in Whitepaper (How to handle inventory manag...) and "Total quantity stock"
    is also ok. The problem is
    that I can't validate the Stocks for last years. I use the transaction MB5B in R3 and I enter
    the selection date for ex. 30.11.2005 for particular Material and Plant (Stock type is valuated stock).
    I see 5000 PC as stock/value on 01.01.0000, so called "opening stock" which I can't see on BW-Side.
    I use Entry Variables for Fiscal year/Period in the query.
    Which Keyfigure I should use to validate stocks for last years?
    How I can view the stocks for last years in BW and compare it with R3 TR MB5B?
    Thanks for assistance.
    Regards,
    Moha
    [email protected]

    For last one month I am facing problem in watching online videos on my iPod touch. It is not opening or can say loading the online videos. Earlier it used to be work absolutely fine. Any solution for my problem.

  • How to get the "Key" for Dimension in SSAS.

    Hi
    How to get the "Key" for Dimension in SSAS.
    (Below value is the PPSParameters table XML column value in PPSDatabase in SharePoint.
    Below three key values are belongs to "Dimension". I have tried to find the key but I could net get it.)
    <NewDataSet>
    <UserValues><Key>16A201A9E75128559F947D58E6D187A9</Key></UserValues>
    <UserValues><Key>7FBEA449A6ED5606973306445839619E</Key></UserValues>
    <UserValues><Key>A8F75F9720817BCD2E1DFC1C1CF1E678</Key></UserValues>
    </NewDataSet>
    Thanks & Regards
    Poomani Sankaran

    To Be Honest there is not one straight Cmdlet that atleast I have come across 
    The best way would if you have Lync monitoring server 
    Using the Lync Server 2013 Monitoring Server
    If you have the Monitoring Server role configured in your environment, and for Lync Server 2013 everyone should!, you can use information contained in the LcsCDR database to pull back the last time a user signed in.  You can run the following query* to
    pull back the user's SIP URI and their last login time:
    USE LcsCDR
    SELECT dbo.Users.UserUri, dbo.UserStatistics.LastLogInTime
    FROM dbo.UserStatistics
    JOIN dbo.Users ON dbo.Users.UserId = dbo.UserStatistics.UserId
    ORDER BY UserUri
    Which produces the following output:
    The advantage to using the Monitoring Server to obtain this data is that unlike the information contained in the rtcdyn database, the information from the LcsCDR data will persist even when the user isn't signed into Lync.
    To get approx count of users enable for Lync Server in your organisation 
    Get-CsUser -Filter {Enabled -eq $true} | MeasurE
    Please not the above command let will give you an approx number not exact 
    From the Monitoring report yet the SIP account that signed in and then from count find out how many user havent signed in this is manual task 
    Hope this is helpful 
    Please remember, if you see a post that helped you please click ;Vote As Helpful" and if it answered your question please click "Mark As Answer" Regards Edwin Anthony Joseph

  • How to get money back for Nokia n97?

     Hi Guys!
     I gave up with Nokia N97!!! I have a lot of problems with it. All of them are known. While this 2,5 months of using the device I was so **bleep** off and felt very uncomfortable while using it! Is that what we paid $700 for?? To see how good it is in the official video commercial and how damn SLOW, buggy and how bad the hardware is? I waited for software update and was hoping to see nice and fast device, oh! and working GPS! Instead - it's still the same "smart" which is most worse on nokia market. That's enough!    
     So now I have this question: How to get money back for Nokia n97 after 2,5 months of usage? or maybe exchange to n900? I will call to customer care center soon but maybe  someone of you have done this already and you can give some tips? 
     Thank You! 
     Cheers
     Hi guys!

    put it up for sale, you have used it for over 30 days nokia will not give you a refund. sell it and buy yourself another device in this case. im giving mine away to a friend. he likes the n97 so its a win win
    You know what I love about you the most, the fact that you are not me ! In love with technology and all that it can offer. Join me in discovery....

  • How to get pc-doctor for win7?

    How to get pc-doctor for win7?  Thanks.
    This question was solved.
    View Solution.

    Hi,
    The PC Doctor version that HP had  provided on some PCs using VISTA was licensed software.  If you are still running VISTA then your can burn a bootable CD containing PC Doctor. A non-OEM license for PC Doctor is quite expensive the last time that I had checked.
    HP DV9700, t9300, Nvidia 8600, 4GB, Crucial C300 128GB SSD
    HP Photosmart Premium C309G, HP Photosmart 6520
    HP Touchpad, HP Chromebook 11
    Custom i7-4770k,Z-87, 8GB, Vertex 3 SSD, Samsung EVO SSD, Corsair HX650,GTX 760
    Custom i7-4790k,Z-97, 16GB, Vertex 3 SSD, Plextor M.2 SSD, Samsung EVO SSD, Corsair HX650, GTX 660TI
    Windows 7/8 UEFI/Legacy mode, MBR/GPT

  • How to get this information for Conky

    Hi people,
    My question is how to get this information for show in Conky:
    - KDE version.
    - Last sync (pacman -Sy) and Last update (pacman -Su)
    For the first point could be use a script that execute $ kdesu --version and get information from there.
    I have no idea how get information from pacman (may be logs?).
    Any ideas?
    Thank you.

    I have had tremendous success with LUA in Conky on Arch. And all you need to to is put the text HI after the "TEXT" line. ^^;
    Examples of my LUA usage:
    http://fc02.deviantart.net/fs71/i/2010/ … usLink.png
    http://kittykatt.silverirc.com/screens/conky-HUD.png
    EDIT:  Also, I've had success with getting the KDE version by doing the following...
    kwin --version | awk '/^Qt/ {data="Qt v" $2};/^KDE/ {data=$2 " (" data ")"};END{print data}'
    This is the method I'm currently using in screenFetch. Tested it a couple of times myself, but besides that, I'm not sure if it will work or not.
    Last edited by kittykatt (2010-04-22 17:52:25)

Maybe you are looking for