Show records corresponding to last date of last 3 months
Experts,
I have a list of records in my logical table like this. All I need to do is create an analysis that will show the records corresponding to last date of the last 3 months. Assuming current month is July. The report must show only the highlighted records. I'm using OBIEE11g
customer product region Date
AAA 123 US 7/28/2012
AAA 234 US 7/31/2012
AAA 112 US 7/31/2012
BBB 232 CN 6/21/2012
BBB 232 CN 6/30/2012
CCC 132 IN 6/30/2012
DDD 322 IN 5/31/2012
AAA 234 US 4/30/2012
AAA 222 US 4/29/2012
BBB 112 CN 3/31/2012
BBB 111 CN 3/22/2012
Thanks for your help in advance
You have to create appropriate filters for your analysis.
1. Create filter on a Day column.
Choose "is between".
The cursor have to be in a edit box under first "Value".
Press "Add" button and choose "SQL Expression". So the "Value" must to change into "SQL Expression".
Enter the next formula
TIMESTAMPADD(SQL_TSI_DAY,1-DAYOFMONTH(TIMESTAMPADD(SQL_TSI_MONTH, -2, CURRENT_DATE)),TIMESTAMPADD(SQL_TSI_MONTH, -2, CURRENT_DATE)) Move cursor into next "Value". Press "Add" button and choose "SQL Expression". Enter the CURRENT_DATE into it and press "Ok".
2. Add another filter on a Day column for example
"Calendar"."Day" is equal to / is in <current day>
Then edit filter. Press an icon at right of this filter and chhose "Edit Formula Column...".
Enter the next formula
MONTH(TIMESTAMPADD(SQL_TSI_DAY,1,"Calendar"."Day")) - MONTH("Calendar"."Day")Press "Ok".
Then edit filter once again. Press an icon at right of this filter and chhose "Edit Filter...".
In a "Value" edit box write "1" and press "Ok".
Run analysis and you'll get your requirements.
Similar Messages
-
Hi All,
Can anyone tell me the logic to get the last date of the month for vbrk-fkdat. The date format is dd/mm/yyyy. i need the output on the same format.
for ex: if vbrk-fkdat = 17/12/2007 the output should be 31/12/2007.
Thanks,
Madhuactually the FM only takes date like sy-datum. but my variable is
i had made the changes like -
data: gv_date(10) TYPE c,
gv_date1(10) TYPE c.
CONCATENATE wa_vbrk-fkdat6(2) wa_vbrk-fkdat4(2) wa_vbrk-fkdat+0(4) INTO gv_date SEPARATED BY '/'.
REPLACE ALL OCCURRENCES OF '/' IN gv_date WITH '.'.
CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
EXPORTING
day_in = gv_date
IMPORTING
last_day_of_month = gv_date1.
REPLACE ALL OCCURRENCES OF '.' IN gv_date1 WITH '/'.
but its showing the error as the variable declaration is different as it is in FM, i.e FM contains date type sy-datum.
please reply ASAP.
Thanks,
madhu -
Get Last date of every Month in a year
Hi All,
I need to find last date of month for given year.
Example:
I used to pass date or year such as 2012 or 01-01-2012(DD-MM-YYYY)
SQL query needs to return last date of every month such as
31-01-2012
28-02-2012
31-03-2012
30-04-2012
31-12-2012
for above requirement i have written the following SQL
select rownum as row_count,
case when rownum=1 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as Jan_month,
case when rownum=2 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as Feb_month,
case when rownum=3 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as mar_month,
case when rownum=4 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as apr_month,
case when rownum=5 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as may_month,
case when rownum=6 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as jun_month,
case when rownum=7 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as jul_month,
case when rownum=8 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as aug_month,
case when rownum=9 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as sep_month,
case when rownum=10 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as oct_month,
case when rownum=11 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as nov_month,
case when rownum=12 then last_day(to_date(add_months(trunc(to_date('01-01-2012','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as dec_month
from dual connect by level <= 12 order by rownum;
Result
Jan_Month
Feb_Month
Mar_Month
Apr_Month
may_month
jun_month
jul_month
aug_month
sep_month
oct_month
nov_month
dec_month
1
31-01-2014
2
28-02-2014
3
31-03-2014
4
30-04-2014
5
31-05-2014
6
30-06-2014
7
31-07-2014
8
31-08-2014
9
30-09-2014
10
31-10-2014
11
30-11-2014
12
31-12-2012
Excepted Result:
am excepted result as single row such as
Jan_Month
Feb_Month
Mar_Month
Apr_Month
may_month
jun_month
jul_month
aug_month
sep_month
oct_month
nov_month
dec_month
31-01-2012
28-02-2012
31-03-2012
30-04-2012
31-05-2012
30-06-2012
31-07-2012
31-08-2012
30-09-2012
31-10-2012
30-11-2012
31-12-2012
Kindly give me suggestion to archive above result.
Thanks&Regards
SamiI agree with Marcus Pivot is the way to go about this... But on the other hand you almost solved it yourself.. just a max function was needed for your expected output:
select
max(case when rownum=1 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as Jan_month,
max(case when rownum=2 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as Feb_month,
max(case when rownum=3 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as mar_month,
max(case when rownum=4 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as apr_month,
max(case when rownum=5 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as may_month,
max(case when rownum=6 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as jun_month,
max(case when rownum=7 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as jul_month,
max(case when rownum=8 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as aug_month,
max(case when rownum=9 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as sep_month,
max(case when rownum=10 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as oct_month,
max(case when rownum=11 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as nov_month,
max(case when rownum=12 then last_day(to_date(add_months(trunc(to_date('01-01-2012','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as dec_month
from dual connect by level <= 12 order by rownum;
AND to avoid hardcoding you can also modify your query as :
select
max(case when rownum=1 then last_day(to_date(to_char(rownum),'MM')) end) as Jan_month,
max(case when rownum=2 then last_day(to_date(to_char(rownum),'MM')) end) as Feb_month,
max(case when rownum=3 then last_day(to_date(to_char(rownum),'MM')) end) as mar_month,
max(case when rownum=4 then last_day(to_date(to_char(rownum),'MM')) end) as apr_month,
max(case when rownum=5 then last_day(to_date(to_char(rownum),'MM')) end) as may_month,
max(case when rownum=6 then last_day(to_date(to_char(rownum),'MM')) end) as jun_month,
max(case when rownum=7 then last_day(to_date(to_char(rownum),'MM')) end) as jul_month,
max(case when rownum=8 then last_day(to_date(to_char(rownum),'MM')) end) as aug_month,
max(case when rownum=9 then last_day(to_date(to_char(rownum),'MM')) end) as sep_month,
max(case when rownum=10 then last_day(to_date(to_char(rownum),'MM')) end) as oct_month,
max(case when rownum=11 then last_day(to_date(to_char(rownum),'MM')) end) as nov_month,
max(case when rownum=12 then last_day(to_date(to_char(rownum),'MM')) end) as dec_month
from dual connect by level <= 12 order by rownum;
Easy way: (without connect)
SELECT LAST_DAY (TO_DATE (ROWNUM, 'MM')) AS Jan_month,
LAST_DAY (TO_DATE (ROWNUM + 1, 'MM')) AS Feb_month,
LAST_DAY (TO_DATE (ROWNUM + 2, 'MM')) AS Mar_month,
LAST_DAY (TO_DATE (ROWNUM + 3, 'MM')) AS Apr_month,
LAST_DAY (TO_DATE (ROWNUM + 4, 'MM')) AS May_month,
LAST_DAY (TO_DATE (ROWNUM + 5, 'MM')) AS Jun_month,
LAST_DAY (TO_DATE (ROWNUM + 6, 'MM')) AS Jul_month,
LAST_DAY (TO_DATE (ROWNUM + 7, 'MM')) AS Aug_month,
LAST_DAY (TO_DATE (ROWNUM + 8, 'MM')) AS Sep_month,
LAST_DAY (TO_DATE (ROWNUM + 9, 'MM')) AS Oct_month,
LAST_DAY (TO_DATE (ROWNUM + 10, 'MM')) AS Nov_month,
LAST_DAY (TO_DATE (ROWNUM + 11, 'MM')) AS Dec_month
FROM DUAL
Cheers,
Manik. -
Variable last date of previous month/last date of current month
Hello Experts,
I am facing an issue while designing a query.
Requirement is like this.
Report will be run on monthly basis.so on execution of report, it should prompt for month/year.
now on report there are two columns for which I have to get data on date basis(last date of previous month and Last date of current month).
Can anyone tell me is there any standard variable for this? what is it?
or how to achieve this?
Regards,
NiravHi,
See if this post in this forum can help you.
Re: Last date of a month
Regards
Shalabh Jain -
First and Last date of any Month.
Hi Friends,
I have 2 fields in my table
FROM DATE & TO DATE
User can enter any date in these two fields, but at time of commit i want to change the FROM DATE to the first date of the Month user have entered. And for TO DATE i want to change the last date of the month.
For Example :
User Enters-
FROM DATE 12-Mar-2003
TO DATE 27-Jun-2003
I want to change these date to:
FROM DATE 01-Mar-2003
TO DATE 30-Jun-2003
How can I write a database function or procedure to control this thing.
Please help.
Best regards,
Imran BaigIt depends on your requirements, but I usually use TRUNC(date, 'D')
to get the first day(Sunday) of the week, because TRUNC(date, 'W')
returns the same day of the week as the first day of the month.
See http://download-west.oracle.com/docs/cd/A87860_01/doc/server.817/a85397/function.htm#80101
for more info on this. -
Terms of Payment to determine due date as last date of the month
Hi Experts,
Does any one know how to configure a Terms of Payment to determine due date as last date of the month ?
I tried by puting fixed date as 31 in the Terms of Payment in FI but when I am creating in FI-CA it gives me an error "_Term of payment Z003 is inconsistent/not planned_"
Please advice.
Thanks & Regards
SatyajeetHi Satyajeet,
It seems the settings that you have maintained in FI are correct.
When you are assigning the payment terms in FI-CA, you need to assign a factory calendar as well to the payment terms in the following config-
IMG->Financial Accounting ->Contract Accounts Receivable and Payable->Postings and Documents->Document->Maintain Payment Terms
If you have already assigned the factory calendar and still the problem persists, can you give the message ID and the message number of the error that you are getting?
Thanks,
Amlan -
Want last date of the month as default basic finish date for the Proc order
For forward scheduling type in process order, irrespective of the start date i want last date of the month as my basic finish date.
Ex start date can be 01/10/2009 or 15/10/2009, but the basic finish date should be 31/10/2009.Hi Sam,
sorry to say , its not possible in standard SAP.
1) If, on order creation, a planned order exists for the production order/ process order, the basic dates are copied from the planned order.
2)If no planned order exists on order creation, you must specify at least one basic date.
The scheduling type determines the basic dates that you must specify. and it useses timings from routings for scheduling.
so may be you need some work around.
explain your requirement why do you want to fix it for the last day of month and other constraints, may be we can find some way.
Regards
Ritesh -
i have a scenario where i need the data of last date of every month and if the month is current month need current date data...
is it possible using MDX...Hi Shashi,
According to your description, you want to return the last day for each month except current month, right?
In MDX, we can use ClosingPeriod function to return the member that is the last sibling among the descendants of a specified member at a specified level, here is a sample query for you reference.
with member [measures].[a]
as
ClosingPeriod ([Date].[Calendar].[Date],[Date].[Calendar].currentmember).name
select {[measures].[a]} on 0,
[Date].[Calendar].[Month].members on 1
from
[Adventure Works]
And then use the IIF function to evaluate if the month is current month. Please refer to the links below.
http://msdn.microsoft.com/en-us/library/ms145584.aspxhttp://msdn.microsoft.com/en-IN/library/ms145994.aspx
Regards,
Charlie Liao
TechNet Community Support -
To display Last Date of the Month in Financial Reporting studio 9
Hi
I want to display last date of the month in header in Financial Reporting studio 9 . Is there any function which displays the last date of the month as per user selection .
for example
If user select month of Jan it should display Jan 31st, 2009
If user select month of Feb it should display Feb 28th 2009
ThanksUnless you name your Months like that you cannot do it. A large team from a major consulting firm told me for a year that it was not possible and convinced management that financial statements don't need dates.
Management decided that we do need dates (because all financials need dates, look at any text book). I figured out a pretty sweet solution that is simple and easy to use and maintain. The users love it. Management loves it.
I'm not giving it away though. -
Hi Experts,
How to get last date of last quarter from SYSDATE
Thanks
VSQL> select trunc(sysdate,'q')-1 from dual;
TRUNC(SYS
31-MAR-11Max -
Hello....
I want to get the last date of the month.
For example, the last date of Jan is 31.
How can I get the last date of the particular month and year ????
Thanks for help.
GloriaHi Gloria
1. How can I compare the date???date1.compareTo(date2)
where date1 and date2 is a java.util.Date Object
will return 0 if it is the same date
or
date1.after(date2)
where date1 and date2 is a java.util.Date Object
will return true if date1 is after date2
(the same for date1.before)
2. How can I change the date format into yyyymmdd format???? I just want the year, month and date.try the java.text.SimpleDateFormat Object
new SimpleDateFormat("yyyymmdd").format(yourdate)
Hope this help.
Please also have a look at a calendar I wrote, (maybe it help)
demo & source :
http://www.geocities.com/globe_software/java/components/
globe_sa -
Dear ALL,
How to find out the last date of a month for a paticular date field.
Regards,
Nikhil.Hi,
sample code for calculating ..last day of month
zdate like sy-datum.
zl_date like sy-datum.
WHEN 'Var1'. ' month variable for last date of month
IF I_STEP = 2.
LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
WHERE VNAM = 'Var0'. 'current date or any date of month
CLEAR L_S_RANGE.
IF sy-subrc eq 0.
zdate = LOC_VAR_RANGE-low.
CALL FUNCTION SLS_MISC_GET_LAST_DAY_OF_MONTH.
EXPORTING
DAY_IN = zdate
IMPORTING
LAST_DAY_OF_MONTH = zl_date
EXCEPTIONS
DAY_IN_NOT_VALID.
if sy-subrc eq 0.
L_S_RANGE-LOW = zl_date.
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'EQ'.
APPEND L_S_RANGE TO E_T_RANGE.
endif.
endif.
ENDLOOP.
i hope you have how to document for creating Customer exit variable. if not post your mail id.
Regards,
San!
Message was edited by: San! -
ABAP code to derive last date of the month from month input.
Hi ,
how to derive the last date of of month for the for user exit variable
Hussain ReddyHi,
See the following code.. .
WHEN 'ZLDAY'. " Customer Exit variable on 0CALDAY
IF i_step = 2.
data: fd type sy-datum,
ld type sy-datum.
LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'ZDAY'. " User entry date on 0CALDAY
IF sy-subrc = 0.
CLEAR: l_s_range.
fd = loc_var_range-low.
CALL FUNCTION 'SLS_MISC_GET_LAST_DAY_OF_MONTH'
EXPORTING
day_in = fd
IMPORTING
last_day_of_month =
* EXCEPTIONS
* DAY_IN_NOT_VALID = 1
* OTHERS = 2
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
l_s_range-low = ld.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
ENDIF.
ENDIF.
Simple Program.
Just copy past in SE38 and test and use the logic for your requiremet
REPORT ztest1.
data: fd type sy-datum,
ld type sy-datum.
fd = sy-datum.
CALL FUNCTION 'SLS_MISC_GET_LAST_DAY_OF_MONTH'
EXPORTING
day_in = fd
IMPORTING
LAST_DAY_OF_MONTH = ld
* EXCEPTIONS
* DAY_IN_NOT_VALID = 1
* OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
write:/ ld.
further help on exitc you ca see the articles.
https://wiki.sdn.sap.com/wiki/display/profile/Surendra+Reddy
Thanks
Reddy
Edited by: Surendra Reddy on Dec 15, 2009 11:38 AM -
How we claculate the first and last date of the month
hi,
I have a requirement, if i have the any date of a month like today date 02/13/2008. So i want the first date of this month and the last date of this month.
Is there any FM for this..or if you have nay prorgam pls send to me.
thanks.Hi Vipin,
Try
HR_JP_MONTH_BEGIN_END_DATE FM will return both first day and last day
LAST_DAY_OF_MONTHS for getting last day of month.
Reward if helpful.
Regards,
Mandeep -
How can we see Last Date and last quantities in Bex Analyzer ?
Hı BW Gurus,
I have a query that shows consumption quantities for a material regarding to a date interval. On initial screen i specify a material and a date interval ( 01.04.2007 - 15.04.2007 for example). Then query brings total consumptions(261 and 601 movement types) for materials. I set up the query according to stock cube.
But my client wants the last consumptions (last 601 and last 261) quantities and dates in a different columns. When we include calendar day it can be seen easily all the lines day by day. But we dont want to include calendar day. Thus for one material only one row will be exist. Report template will be like that:
On initial screen we defined april 2007 , Output:
Material Total consump. quantity Last Consump. Quant. Last.Cons.Date
XYZ 457 76 18.04.2007
PS: 76 is included in 457.
How can we achieve this result?
Thank you all indeed
Evren Temiz
Message was edited by:
Evren TemizHi Evren,
What do you mean?
Regards.
Maybe you are looking for
-
Replacing MacBook Pro Screen with higher resolution screen?
I bought a MacBook Pro 15" today which has the lower end screen resolution. I originally wanted the higher resolution screen but the guys in the shop said they didn't sell them in the shops, only online, but since I wanted one before I headed off to
-
Any way in EBS for purchase dept to raise a request for a prepayment
hello This morning i received a request from accounts department that they would not enter prepayments manually . Instead it should be like a PO process: the requestfor prepayment should be raised from purchasing department which should be approved a
-
Portal Gurus, I have a requirement to integrate the IS for utilities in the portal. Is there a business package that handles this function or is the functionality involved in the CRM business package by any chance? how do you think we can implem
-
Are there any Citrix Dazzle users on this community?
For various and sundry reasons, I need to run certain apps on my Mac mini via Citrix Dazzle where the apps in question live on a Windows Xenapp server. I have two questions about this configuration. Unfortunately, the guy who runs my employer's Xenap
-
SlingScriptHelper object in OSGi Service
Hi, I am writing OSGi Service and I would like to get all services with given class ContentBuilder.class like in the Replication dialog: Object[] builders = sling.getServices(ContentBuilder.class, null); It requires to create "sling" object of type S