Previous month is easy, what about most recent date WITH data?

As the topic suggests, I've seen many posts with the following solution for returning the last date of the previous month: TIMESTAMPADD(SQL_TSI_DAY,DAYOFMONTH(CURRENT_DATE) * -1 , TIMESTAMPADD(SQL_TSI_MONTH, 1, CURRENT_DATE)).
However, for at least the first few days of the current month, no data will be available for the previous month. How can I tell OBIEE to return the date for the most recent month where data exists?
Another part of this puzzle, is that this request needs to play nicely with query rewrite in the view. the TIMESTAMPADD doesn't seem to use query rewrite well. Any suggestions?

jzuzphreek wrote:
As the topic suggests, I've seen many posts with the following solution for returning the last date of the previous month: TIMESTAMPADD(SQL_TSI_DAY,DAYOFMONTH(CURRENT_DATE) * -1 , TIMESTAMPADD(SQL_TSI_MONTH, 1, CURRENT_DATE)).
However, for at least the first few days of the current month, no data will be available for the previous month. How can I tell OBIEE to return the date for the most recent month where data exists?
Another part of this puzzle, is that this request needs to play nicely with query rewrite in the view. the TIMESTAMPADD doesn't seem to use query rewrite well. Any suggestions?For what you presented, the answer is simple. However, I suspect that your need is not as simple as you described. You describe your scenario as "there are no data for the previous month for the first few days of the current month." There are two inherent assumptions which if true, makes the problem not that difficult:
1) Only the first few days of the current month, there are no data for the previous month (i.e., for the rest of the month, the data are there.)
2) Data exists for every month.
With these two assumptions, here is how you build your dashboard.
1) Create a simple report with the key data fields run with the filter for "current month."
For the "first few days" of the current month, this report will yield no records. (It doesn't matter how many days "a few days" is as you will see.) For the "rest of the month," this small report will always yield at least one record.
2) Create your main report (call this Report A) that has a filter for "previous month."
3) Place Report A on your dashboard in a Section.
4) Click on the Properties of the Section and select "Guided Navigation" and have it point to the small report you built in step 1) that will display the section "if the request returns rows."
5) Build another report (call this Report B) that has a filter for "two months ago."
6) Place Report B in a separate Section on your dashboard, below the Section in step 3).
7) Click on the Properties of this Section and again select "Guided Navigation," have it point to the small report from step 1), but this time have it display "if the request returns no rows."
So here's what happens. For the first few days of "this month," the small report will return no rows. The top Section will not display, but the bottom one will, which has as its filter "two months ago." The assumption is that by the end of each month, there will always be data. This therefore meets your criteria of displaying "the most recent month where data exists." Once data for "this month" is available, the top Section will display with the current month's filter. The bottom section will not appear until the "first few days" of the next month.
That's how you do it.

Similar Messages

  • Is there a way to get back a previous iTunes backup file than the most recent Backup?

    I did a manual backup and wanted to restore the iPhone, but iTunes forced me to update the iPhone before allowing me to restore the iPhone...
    After updating, I realised that iTunes created a backup automatically without confirming with me, and now the latest backup file is not the one I wanted.
    Is there a way to get back the backup file I manually backup?

    Is there a way to get back a previous iTunes backup file than the most recent Backup?
    No, to the best of my knowledge the device backup area is simply updated with new information each time the device is backed up so there are no previous versions preserved. Once a backup has been used to restore a device however it gets locked and dated so that you could return back to that snapshot at a later date.
    Your manual backup should have simply updated the backup with any new data since the last automatic backup. Upgrading should not have overwritten a backup taken just before the upgrade with a, presumably, empty state. Have you actually tried to restore the current backup that is available? It may have what you want after all. You might like to try backing up the current state of the device to iCloud first, or if you have access to another computer back it up to that.
    N.b. I always disable automatic syncing of devices so that I am in better control of when data starts to be written, and in which direction it flows.
    ttt2

  • How can i determine what the most recent os my imac will run?

    How can i determine what the most recent os my iMac will run?
    Serial Number QP6*****VUW
    Processor 2.16 GHz Intel Core 2 Duo
    Currently running Version 10.5.8
    <Edited by Host>

    You CAN run 10.7, but I don't advise it, buy the 10.6.3 upgrade disk from the Apple Store online and then backup files off the machine and upgrade to 10.6.3., then Software Update to 10.6.8 would be the BEST option for your older hardware and it will run most all of your 10.5 software and be faster than 10.5 or 10.7.
    If you go to 10.7 it won't run nearly any of your 10.5 software and you will have to buy all new ones for a machine that's getting a little bit dated, near it's end of life stage. 10.7 will slow your machine down, especially with low RAM.
    http://roaringapps.com/apps:table
    At your machines stage, the hard drive is getting old, the vents are clogged up with dust and it's going to cost a bit to get the drive etc upgraded. You can if you wish, but 10.7 really needs more RAM (4GB) and a faster hard drive.
    But your still subjected to the video card going out etc.
    IMO upgrade to 10.6.8 and stay there until the wheels fall off, then buy a new 10.8 machine being released after this summer or 10.9 machine.
    Harden your Mac against malware attacks

  • What is Most recent Safari Windows Version?

    I am doing some QC testing and the client is rejecting bugs found using Safari 4, claiming that all their traffic is Safari 5. I don't have access to a PC this weekend so can someone tell me what the most recent Windows Safari Version/Build number is, and also if they are familiar with Safari 5?
    Thx

    Hi,
    Safari 4.0 (530.17) is the latest version for Windows.
    Apple have not announced any plans for Safari 5 at this time (maybe the client means all their traffic is from Safari 3?).

  • Selecting row by most recent date

    I'm attempting to select a row where the time ends in :00 and
    date is the most recent date or just the last record where time
    ends in :00, either will do.
    Once I have that record selected I need to query that query
    to pull in the previous 3 records which will be times ending in
    :15, :30 and :45 to round out that full hour of data for
    processing.
    It seems to me that this should be pretty easy but my CF
    books are not helping me here.
    Any Ideas?

    Two things I do to make this sort of thing easier are:
    1. Take baby steps. Start with one field and the date field.
    Once you get that to work, add one or two fields at at time.
    2. Comma control. This structure helps prevent extra commas
    from slipping into your query.
    select field1
    , field2
    , date
    from yourtable join (
    select field1 f1
    , field2 f2
    , max(datefield) maxdate)
    from yourtable
    where something
    group by field1
    , field2
    ) temp on field1 = f1 etc
    where clause

  • How to display maximum (most recent) date value in a query

    hello,
    I have the following query:
    StudentNumber | ExternalOrganization | Date |         | NumbeOfAdmissions
    0112                  050                            06/27/2007   1
    0234                  060                            07/15/2008   1
    1356                  025                            01/08/2008   1
    My dilemma is how to display only the row that has the most recent Date, e.g. here I want to only see the row with student number 0234 and date 07/15/2008; everything else should be hidden.
    I know it should be very simple....yes/no?
    thanks

    Hi
    even I am facing the same problem..
    Can you please tell me what did you do to get most recent record..
    Even I have made my date field as KF.. n have put condition on it.. but not getting desired result.. may be I am missing something.. somewhere..
    I resolved it.. thanks
    Regards
    Swati
    Edited by: Swati on Feb 17, 2009 7:49 AM

  • Most recent date with two other conditions met

    Ok, so I'm sure somebody is going to suggest that I do a search first before posting on here.  So let me assure you, that I have exhausted all search possibilities that I could possibly think of before registering to post on here.  I've read a lot of good suggestions that got me just as far as I was getting on my own, because I couldn't find any posts of somebody asking exactly what I'm looking to do.  I have tried quite close to 100 different formulas without achieving the desired results.
    I'm a pilot, and I track all of my flights myself in a very well organized(I think so ) Numbers spreadsheet that I've been tweaking and perfecting over the past few years.  I have created plenty of formulas in it, and they all work great...except ONE.
    I've created a simplified version of the columns I am trying to match specific conditions with.  Essentially, I need the formula to return the most recent date(column 1), that is completed during a night time flight status(column 2), that is equal to or greater than 1.0 flight hours(column 3).
    As you can see, by evaluating the table below, the correct formula should return to me:        8-4-13
    The closest I've come to getting the correct results was with a "LOOKUP" formula, but I could not figure out how to get it to properly assess whether it was equal to or greater than 1.0 hours of flight, thus returning me the wrong date EVERYTIME(the most recent night flight period).
    I'm sure I've gotten close at least a few times, but I need some help getting this final formula figured out.  I really appreciate anybody's input on this.
    Date
    Flight Status
    Flight Hours
    8-1-13
    D
    2.4
    8-2-13
    N
    3.0
    8-3-13
    N
    1.1
    8-4-13
    N
    1.3
    8-5-13
    D
    2.2
    8-6-13
    N
    0.5
    8-7-13
    D
    1.1

    This may work and requires and extra column in your Data entry table (the one you provided in your post).  You can hide this new column.
    D2=IF(AND(C2>=1, B2="N"), A2, "")
    select D2 and fill down as needed.
    The table on the right is a summary table and is set up as follows:
    B2=MAX(Data :: D)
    I hope this is helpful

  • Most recent date (UDATE) from CDHDR table based on CDPOS

    Hi,
    I am working on one object where i stuck with one issue. The requirement is I have to retrieve the most recent date from CDHDR table based on CHANGENR in CDPOS table. Where i am doing FOR ALL ENTRIES on CDPOS table to get the MAX( date )and i got the error, that aggregate functions are not allowed except COUNT( * ) with for all entries.
    Any thread which can solve this issue would help aswel.
    Please guide me how to achieve this. <removed>
    Edited by: Thomas Zloch on Mar 13, 2010 9:10 PM

    Hi Li,
    Thats was really helpful information , infact my requirement is same as what you said. I even checked in the table entries there is only one changenumber.
    You said we can take the first record, i even did the same. But for TABNAME I have to pass 3 table name 'LFA1', 'LFB1' and 'LFM1'. For FNAME 'LOEVM', 'SPERR'. I have written the code as below.
      SELECT objectclas
                   objectid
                   changenr
                   FROM cdpos
                   INTO TABLE i_cdpos_a1
                   FOR ALL ENTRIES IN i_lfabm1
                   WHERE objectclas = c_kred               "KRED
                   AND objectid EQ i_lfabm1-objectid       "Lifnr
                   AND ( tabname EQ c_lfa1 OR tabname EQ c_lfb1 OR tabname EQ c_lfm1 )          "LFA1, LFB1 and LFM1
                   AND ( fname EQ c_loevm OR fname OR fname EQ c_sperr )    "LOEVM, SPERR
                   AND value_new EQ c_x.
            IF sy-subrc EQ c_0.
              IF i_cdpos_a1[] IS NOT INITIAL.
    Select UDATE from CDHDR based on CHANGENR in CDPOS.
                SELECT objectclas
                       objectid
                       changenr
                       udate
                       FROM cdhdr
                       INTO TABLE i_cdhdr_a1
                       FOR ALL ENTRIES IN i_cdpos_a1
                       WHERE objectclas = c_kred             "KRED
                       AND  objectid EQ i_lfabm1-objectid               "Lifnr
                       AND changenr EQ i_cdpos_a1-changenr.   "(this is coming from CDPOS above selection)
    Here i got UDATE which have all the dates from 3 tables. I have to display in the output the field value (X) of LOEVM and UDATE for LFA1, SPERR value and UDATE for LFA1.Same way for other two tables, I have to display the UDATE and its field value (X). Where UDATE should be most recent date respectively.
    How can I populate the Recent date (UDATE) from one interal table for indvidual field values and table names.

  • Most recent date query..

    Hi All..
    I have 2 tables note and sub_note and sample data is..
    create table note(note_date date,pmry_id number,sub_id number not null)
    insert into note(note_date,pmry_id,sub_id) values('12/30/2008 02:12:52',282,1)
    insert into note(note_date,pmry_id,sub_id) values('12/23/2008 10:12:24',282,1)
    insert into note(note_date,pmry_id,sub_id) values('12/22/2008 01:12:11',282,1)
    insert into note(note_date,pmry_id,sub_id) values('12/22/2008 09:12:56',282,1)
    insert into note(note_date,pmry_id,sub_id) values('12/19/2008 01:12:54',282,1)
    insert into note(note_date,pmry_id,sub_id) values('12/22/2008 09:12:56',282,2)
    insert into note(note_date,pmry_id,sub_id) values('12/22/2008 09:12:57',282,2)
    create table sub_note(sub_id number not null,sub_name varchar2(100))
    insert into sub_note(sub_id,sub_name) values(1,'Product')
    insert into sub_note(sub_id,sub_name) values(2,'Expectations')how can select the most recent date for product and most recent date for expectations...joining these 2 tables..
    Thanks in advance...

    user10280715 wrote:
    Thanks for the reply...
    that was only a sample data..so I kept 2 sub_names for a perticular pmry_id..my original data contains several sub_names(about 5) for a perticular pmry_id...
    hope you gt my point..I'm not sure I understand.
    If you have 5 sub_names that you're interested in, change the WHERE clause to have those 5 sub_names. The list after "IN" can have as few as 1 or as many as 1000 items. (I'm not too sure about the upper limit, and it may be version-dependent.)
    If you want to include all sub_names, then omit the WHERE clause.

  • How to display record with most recent date in sapui5?

    Hi
    I have a local json data with me, in which I have number of records.
    And in each record I have an "AENDATE" as a date property.
    Now I want to display the record with most recent date in the records.
    How I can I do it......????????
    Please help me with this.
    Thanks
    Sathish

    How about sorting your json model descending, and display only first (index:0) item?

  • Select most recent date only

    I'm quite new to discoverer so please bear with me.
    I have a query that returns e.g. 16 records.
    One of the fields is a date field.
    What I want to do is put a condition on the date field so that it only returns the record with the most recent date.
    Thanks.

    let me explain it to u in detail
    i have the following fields
    CONTRACTNUM FIRMTYPE FIRM A FIRM B FIRM % NTP_ACTUAL
    123456 P ABC XXX 96 MM/DD/YYYY
    S XXX DEC 4 MM/DD/YYYY
    P ABC XXX 96 MM/DD/YYYY
    S XXX DEC 4 MM/DD/YYYY
    Here the CONTRACTNUM IS unique and the firm% sum is equal to 100, but the record is repeating twice , under the same CONTRACTNUM......................any suggestions willbe of great help.
    So for this i used the ROW_NUMBER() OVER(ORDER BY date_field DESC)
    in my case : ROW_NUMBER() OVER(ORDER BY ntp_actual DESC).
    Now it gives me a new field with the row_numbers and when i create a condition where the calculation is =1, it give me one record
    I was using this , because for any given contract number .............it should bring the record with the recent ntp_actual date.
    i hope i was clear.
    Thnks

  • TS3899 iOS 7: sort email by most recent date?  Beyond frustrating.

    iOS 7: sort email by most recent date?  Beyond frustrating.

    Agree. Mail search results are nearly useless, sorted in effectively random order. Major Apple FAIL.
    Removing the other search buttons (from, subject, etc.) is also frustrating. Went from one-click simplicity to having to type in 'from:'.  Serious inconvenience.  Completely failed the WWSS (What would Steve Say?) test.

  • Most recent date in report filter.

    Hi,
    I have a report with a date column. I would like to run the report for the most current date. I would like to add a filter to the report which pulls data for the most current as of date. Which would be the best method to use in the filter. Please advise. Thanks.

    First, you need to determine what the date column is that contains the dates you want to filter on. So say you have a Processing Date column which houses the dates transactions are processed.
    1) Add this date column to your workspace.
    2) Click on the filter button of this column and then on Advanced>Convert this filter to SQL.
    3) After the name of the column, enter MAX(date_column). So you will have:
    "Table name"."Date Column" = MAX("Table name"."Date Column")
    Now chances are you will have many reports that need the "most recent date" filter. Therefore, what you should really do is build this filter in the repository and expose it as a Saved Filter for all to use.

  • How do I get the numbers ipad app to plot a graph of dates against values, where the most recent date is on the right of the graph, but the most recent date is at the top rather than bottom of the rows in the table?

    How do I get the numbers ipad app to plot a graph of dates against values, where the most recent date is on the right of the graph, but the most recent date is at the top rather than bottom of the rows in the table?
    Also how can it be a line graph without plotting a circle at each value?
    Thanks this is very frustrating

    Make a copy of the table and produce your Line chart or Bar chart from the copy. Sort the copy into the order you want to see in your chart.
    Alternately you could use a Scatter Chart...
    Jerry

  • "next" most recent date

    Hello!
    I have an order header record with a order line detail table.
    ORDERS
    OrderID > 1
    ORDER_LINES
    orderID1, line1, item1, date_due
    1,1,ITEM1,01-MAR-07
    1,2,ITEM2,15-MAR-07
    1,3,ITEM3,01-ARP-07
    I want to select the single next most recent date from order_lines where the date_due is the next future date closest to sysdate. There could also be several lines with dates beyond that, but I'm only interested in the next most recent line.
    For the example above, if sysdate = 03-MAR-07 the query would return order 1, line 2 (with the date of 15-mar-07).
    I've seen example in the forum with max(), however as pointed out, there could be several future line dates out there, I'm only interested in the next one from the current sysdate.
    In addition there could be no lines at all that map to the order id, requiring a NLV type of test output.
    Thanks!

    Maybe like this?
    SQL> select * from order_lines;
                ORDERID1                LINE1 ITEM1      DATE_DUE
                       1                    1 ITEM1      01-MAR-2007
                       1                    2 ITEM2      15-MAR-2007
                       1                    3 ITEM3      01-APR-2007
    SQL> select *
      2  from
      3  (
      4     select ol.*
      5           ,dense_rank() over (partition by orderid1 order by date_due) dr
      6     from   order_lines ol
      7     where  date_due > trunc(sysdate)
      8  )
      9  where dr = 1;
                ORDERID1                LINE1 ITEM1      DATE_DUE                      DR
                       1                    2 ITEM2      15-MAR-2007                    1

Maybe you are looking for

  • Connecting 3 additional (external) monitors

    Hi all, I'm a professional composer. I've just re-done my studio set up and it looks like this: The two thunderbolt displays seem to work perfectly and I've had no complaints with them. I just can't get the TV to be that 4th monitor. I'd like to flic

  • Tab bar is ~6px bigger with multiple tabs than it is with only one tab

    Example: I open a new FF window. One tab is open. I open a second tab. The tab bar now gains approx. 6 pixels in height. It shrinks back if I reduce the number of tabs I have open to 1. This is annoying. Is there anything that can be done about it? I

  • Premiere Pro Freezes mac while rendering Fast Color Corrector & Rgb curves

    I am having a problem that is impacting our business. We are doing commercials that we are doing color correction of the subject using Fast Color Corrector and RGB curves. When these effects are added to the sequenced video, the performance of the Ma

  • Use of PreparedStatement

    Hello friends, I need help in understanding how the PreparedStatement works. 1. When we first create the PreparedStatement, database parse the sql statement and create the efficient access plan. 2. Then database cache the sql and the access plan. 3.

  • Add Query Reports to My Cockpit

    Hello Experts, Is it possible to add query reports to My Cockpit in SAP 8.81 under the Common Functions window?  If so, how? Currently these reports reside under the My Menu tab which is not enabled when My Cockpit is active.  If this not possible I