Display current and previous months records only
Hello gang,
My selection criteria looks like this:
not ({HRDEPBEN.PLAN_CODE} startswith ["C", "EAP", "HMIL", "V", "W"]) and
(month({hrdepben.Creation_date}) = month(currentdate)) and
{HRDEPBEN.PLAN_TYPE} = "HL"
I modified it to this in order to pull in previous month's data too:
{HRDEPBEN.PLAN_TYPE} = "HL" and
not ({HRDEPBEN.PLAN_CODE} startswith ["C", "EAP", "HMIL", "V", "W"]) and
(month({hrdepben.Creation_date}) = month(currentdate) or month ({hrdepben.Creation_Date})= month (currentdate)-1)
However, it's still pulls the same record count and only January records, not Decembers'.
Where am I going wrong?
Thanks
Looks like you're reporting against Lawson? What database are you using?
There are a few issues with the record selection criteria as it's written:
1) Month(CurrentMonth) - 1 = 0 when the current month is January. That's why your not getting any records from December.
2) The monthly criteria won't be passed to the database for processing, which is a huge performance issue when you're reporting against a system like Lawson. You're basically telling the report to bring back all records that don't start with an array of values, irrespective of the date. Only after all the possible records are returned across the network will the extraneous records be filtered out on the client side. That's bad.
3) It's easy to use StartsWith or Like, but it's also pretty inefficient, since it forces a full table scan of the underlying table
Personally, I'd do one of two things in order to both fix the query and optimize it:
1) Write the underlying query in SQL as either a View or SQL Command object
or
2) Keep the current report, but make use of SQL Expression fields in order to optimize the query.
Here are some examples of SQL Expression fields against Oracle (PL/SQL) that could be useful:
/*{%PLANCODES}*/
/*This SQL Expression evaluates whether or not a Plan Code starts with the specified values*/
/*"HRDEPBEN"."PLAN_CODE" is selected directly from the Field Tree in the SQL Expression Editor*/
CASE
WHEN SUBSTR("HRDEPBEN"."PLAN_CODE",1) IN ('C','V','W') THEN 'Y'
WHEN SUBSTR("HRDEPBEN"."PLAN_CODE",3) = 'EAP' THEN 'Y'
WHEN SUBSTR("HRDEPBEN"."PLAN_CODE",4) = 'HMIL' THEN 'Y'
ELSE 'N'
END
/*{&CREATEDATEMONTH}*/
/*This SQL Expression returns the month of the Creation Date field*/
/*"HRDEPBEN"."CREATION_DATE" is selected directly from the Field Tree in the SQL Expression Editor*/
TO_NUMBER(TO_CHAR("HRDEPBEN"."CREATION_DATE",'mm'))
You could also create formula to return the Month value for last month and then use it in your record selection:
//{@LASTMONTH}
//This formula returns the Month value for Last Month
//IIF statements can be passed to the database for processing
IIF(Month(CurrentDate) = 1, 12, Month(CurrentDate) - 1)
With expressions and formulas like these in place (this code is Oracle and DB2 compatible, it would be different for T-SQL), you could then modify your record selection criteria to be something simpler, like this:
{HRDEPBEN.PLAN_TYPE} = "HL" and
{%PLANCODES} = 'N' and
{%CREATEDATEMONTH} IN {@LASTMONTH} TO MONTH(CURRENTDATE)// MONTH(CURRENTDATE) is passed to the DB
By laying the groundwork, you'll have a much more efficient report and, in the case of the @LastMonth, more accurate! Hope this helps!
p.s. a disclaimer on using SQL Expressions in this manner - it's not officially supported, although it's worked since Version 7 (when SQL Expressions were introduced) and there will be support for them in various 2011 versions. As such, they'll work for years. I use them all the time and they're fantastic for optimizing reports.
Similar Messages
-
Displaying current and previous 5 Year data in a bar graph
Hi ,
My requirement goes like this .....
I have to show revenue (measure) data based on current year (period dimension) selection (from a dashboard prompt) and previous 5 year data's as well .
i.e. if user selects 2013 , the bar graph will display 6 bars ... 2013,2012,2011,2010,2009,2008.
I am trying to achive this with filter on Year column , on the main report ....*"is based on results of another analysis"*
But haven't made any progress .
Thanks
sayaksayak wrote:
Hi ,
My requirement goes like this .....
I have to show revenue (measure) data based on current year (period dimension) selection (from a dashboard prompt) and previous 5 year data's as well .
i.e. if user selects 2013 , the bar graph will display 6 bars ... 2013,2012,2011,2010,2009,2008.
I am trying to achive this with filter on Year column , on the main report ....*"is based on results of another analysis"*
But haven't made any progress .
Thanks
sayakFollow this link. It will give you greater flexibility for you end users and therefore a better report.
http://oraclebizint.wordpress.com/2008/03/11/oracle-bi-ee-101332-rolling-yearmonth-and-date-filters-moving-window-filters/ -
Selective deletion in DSO for current and previous year
Hi,
Can any one give an idea how can I selectively delete current and previous year data (only). is there any process type that can help me in process chains. This should be before loading a fresh load for the same period. this is for psodo delta.
or
any other alternative, plz. suggest.
Thanks
ganesh
Edited by: Ganesh on Jul 7, 2008 12:08 PMHi,
If you have any date value example posting date or 0CALMONTH.., you can filter the date using the selection conditions and selectively delete the data.
Process:
Manage of DSO->Contents Tab->Selective (with delete Icon)->Deletion selections->give the period->Execute->Start->Yes->continue.
Hope this helps..........
Rgs,
I.R.K -
Display current month records only
Hi Experts,
I have the following requirement.
Report should display current month records only.
For example If the report is run on 20090324, It should display records from 20090301 to 20090324.
That means, report may run on any date of that month, It should display from 01 (of that month) to current date.
I have a select statement saying
SELECT * FROM likp
WHERE wadat_ist BETWEEN month_start_date AND sy-datum
AND vkorg IN s_vkorg
AND vkbur IN s_vkbur
AND kunnr IN s_kunnr.
How to calculate date for month_start_date, so that it can display only current month records.
Thanks in advance
RohanHi Kunta, Suhas, Nandi,
Thank you for your quick reply, I really appreciate it.
for this current month records, I need to display a check box saying
Open orders and shipments with the current month.
But where as Selection text is accepting 32 characters only. Is there any possibility to overcome this?
Thanks in advance
Rohan -
Parameter for Current Month and Previous Month
I'm trying to create a parameter for current month and previous month based on the ex_date, but not sure what i'm doing wrong.
where ex_date = @SelectDate
I created a second dataset below for the values in the parameters.
SELECT Month(CURRENT_TIMESTAMP) AS 'Month', 'Current Month' as 'Current Month'
union all
SELECT Month(CURRENT_TIMESTAMP)-1 AS Month, 'Previous Month' as 'Previous Month'
Results
Month Current Month
3 Current Month
2 Previous Month
Once I preview it I get "Conversion failed when converting date and/ or time from character string" I changed the data type to "date/Time" but that did not make a difference. The date is convert (varchar(10), ex_date, 101) so looks like
11/12/2014.
I've also tried expressions like =month(now()) to pull current month with same error so i'm not sure what i'm doing wrong. Any ideas?i tired this real simple report
in the first dataset - my main report query - select name from sysdatabases where month(crdate())=@month
in the second dataset - select month(getdate()) as Month1
in the parameters - choose int data type and available values - select the second data set
in the first data set- add this parameter..( i am assumming you know this, since you have done)
in the preview you should get the drop down with current month number - 3
and if you run the report, it will display the database names that were created in march. remember we are no checking year, so will get all that were created in march across the years.
Hope it Helps!!
I'm looking to have the dropdown say "Previous Month" and "Current Month" as a option. I know how to get the information in SQL, but not sure how this translates or put into a parameter.
Current Month
list_date BETWEEN
DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()), 0)
AND
DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()) + 1, 0)
Previous Month
list_date between
CONVERT(varchar,dateadd(d,-(day(dateadd(m,-1,getdate()-2))),dateadd(m,-1,getdate()-1)),106) /* Last Month */
and
CONVERT(varchar,dateadd(d,-(day(getdate())),getdate()),106) -
Records for parameter month and previous month
Hi,
I have a request where the user parameter is calender year month (YYYYMM).I need to show the records of both the entered month and previous month.
For ex: if the user enters 201107, I need to show the records of 201107 and 201106.
Also,I am not using dashboards.
Any suggestion...
ThanksNo, I don't see this as a solution. A session prompt can only be overridden by using a Request Variable, but they are found in Dashboard prompts which you have excluded as a solution. Therefore, any session variable you set would be "hard-coded" eliminating end-user interaction. Sorry.
You will need to deploy dashboards for this. I will also add this: eliminating dashboards really restricts the power of OBI because it makes it difficult to implement interactive reports such as the one you are building. Perhaps you should use this example as a push to consider adding the value of dashboards to your environment.
As this is useful information to others, please mark applicable posts that resolved your question. Thanks. -
Report that display 'Net Pay' by Empl for current and previous period.
Hi,
We are looking for a SAP report that display 'Net Pay' by Employee for current and previous period in USA payroll module. If you know of any, pl let me know.
Thanks in advance,
NiranjanThanks Archana and Sikindar.
We knew about this report, however, it gives information one below the other if we run, say for 2 periods, but what we are looking for is something as shown in example below
Empl # Empl # Name Prev Pay period Net Pay Current Pay period net pay.
123 XYZ $ 1200.00 $ 1200.00
256 ABC $ 2000.00 $ 3000.00
We want to run for 2 periods at a time and get the results as above. That way, payroll dept can run this report and compare if we are paying too much in current pay, compared to previous pay. This is basically to avoid any typos when they create new pay records in infotype 0008.
Niranjan -
How to Bring the Quarter Period and Previous Month Value for given Input
Hi to all,
I want bring Quarter Period and Previous Month value for the given Input. Plz help me on this
Example :
Input : 06.2008
Output:
Input Prev.Month Quarter 1 Quarter 2 Quarter 3
06.2008 05.2008 03.2008 12.2007 09.2008
12.2008 11.2008 09.2008 06.2008 03.2008
Is there any Standad Exit for this or we have to write coding ?
Regards,
SaranHi,
You can solve this by using Replacement path.There you have a option offsets.Here give the current period.Based on that give the number which previouse month you suppose to want.
I think this 'll help you
assign points if this helps
Regards
JT Goud -
I need to display all the previous months sales.
Hi Gurus,
I have a requirement were i need to display all the previous months sales.
i.e if a user enters sept 2011, then in report it should display from April 2011(which is the first month of fiscal year).h
and also it should display total sales in another column till that month.
Regards
ArunHi,
Part 2 and Part 3 of the document.
Link: [http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f002c608-2533-2c10-25a1-d0e7f7b5b662?QuickLink=index&overridelayout=true]
Link: [http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/10fc4382-afa6-2c10-1380-fa224fe4324f?QuickLink=index&overridelayout=true]
Documents by 'Surendra Kumar Reddy Koduru' are always useful. Try to go through all of them.
All the best!!! -
Need sql querry for getting previous day records only
Hi ,
i have a table with following records,
emp sal date
111 200 03-mar-2011
100 200 03-mar-2008
15 200 06-mar-2012
17 200 03-mar-2003
178 200 03-mar-2004
11 200 11-jun-2012
i need only previous day records only(11 200 11-jun-2012).can any one help on this query?insa wrote:
Except trun you can use Like operator--
select * from emp where date like sysdate-1;
Is it helpful for you?That is most certainly not a helpful answer. the LIKE operator is a string comparison operator and should not be used with dates. Doing so will cause an implicit date to character conversion based on the sessions NLS settings and would be not different to doing:
select * from emp where to_char(date) = to_char(sysdate-1)... which will cause a lack of index usage, and also not deal with any time component within the date.
Please ensure you test your answers before posting them. Several people had already given correct answers here with explanations as to why they are better than other methods. -
No more "current and next month" list on left of iCal
Since the upgrade to Lion, the current and next month list on the left is gone. When I want to reschedule an event, I used to look on the left to see the dates in the next month, or current month if in week view etc .... now it's not there. If I want to change a date, I have to look at another calendar on my wall to reschedule. Can this list be put back on the left?
Mark,
You may want to experiment using the "Year" view. There is a keyboard shortcut (⌘4) for accessing that view.
Can this list be put back on the left?
Let Apple know about your suggestion using Apple - iCal - Feedback. -
Previous month first data and previous month last date
can any body have query to get previous month first date and previous month last date.
Ex: First day of the previous week:
TIMESTAMPADD(SQL_TSI_DAY,-6, (TIMESTAMPADD(SQL_TSI_DAY, DAYOFWEEK(CURRENT_DATE) *-1,CURRENT_DATE)))
Last day of the previous week:
TIMESTAMPADD(SQL_TSI_DAY, DAYOFWEEK(CURRENT_DATE) *-1,CURRENT_DATE)
can anybody have it for first day of the previous month,last day of the previous month?
Edited by: user12255470 on Apr 7, 2010 3:30 AMHi,
1st day of previous month :
TIMESTAMPADD(SQL_TSI_DAY, ( DAYOFMONTH(TIMESTAMPADD(SQL_TSI_MONTH,-1,CURRENT_DATE)) * -1) + 1, TIMESTAMPADD(SQL_TSI_MONTH,-1,CURRENT_DATE))
last day of previous month :
TIMESTAMPADD(SQL_TSI_DAY,DAYOFMONTH(TIMESTAMPADD(SQL_TSI_MONTH,-1,CURRENT_DATE)) * -1 , TIMESTAMPADD(SQL_TSI_MONTH, 1, TIMESTAMPADD(SQL_TSI_MONTH,-1,CURRENT_DATE)))
Please mark Q answered and award points for correct answers !
Thanks
Alastair -
12 month but devided into current and previous year
hi guys
i have this requirement to disaply amount for current period and previous period for 12 month.
Current period is the period of user entered year and previous period is previous year
So if user enter feb 2007 u2026Then current year is feb, jan ,dec 2006
And previous period is Nov 2006 to March 2006
user is entering the value 0CALMONTH ...and report to need to display 12 month internval betwen years. my problem is how to check the year and interval
please help me without any custom exit? can it be possible thru varibale?Hi,
I think i misunderstood your question previously.
You can create offsets on CALMONTH and achieve this easily.
1)In the columns are of query disigner, create selections for 12 months by using CALMONTH and offset each field by -1 or -2,-3,-4 ..... -12.
2) Create a Text Variable to show the month Value in column header
3) Create a structure in columns area and place it below all the CALMONTH selections
4) Include all your Key Figures inside the structure. -
Current month and Previous Month
Hi, I have the table shown above. I m trying to get output something like I need current month total amount and the total of the previous month. Can someone please help on this? THank you
ID PreviousMonthTotal CurrentMOnthTotal
1 3000 3000Please say your @@version,
on
Microsoft SQL Server 2012 (SP1) - 11.0.3412.0 (X64)
Mar 2 2014 01:25:09
Copyright (c) Microsoft Corporation
Standard Edition (64-bit) on Windows NT 6.2 <X64> (Build 9200: )
query show ZEROS.
DECLARE @TEMP as TABLE
id int,date_t datetime,amount int
INSERT @TEMP (id,date_t,amount)
VALUES (1,'20150112',1000)
,(1,'20150212',1000)
,(1,'20150122',2000)
,(1,'20150202',200)
,(1,'20160112',41000)
,(2,'20150112',1001)
,(2,'20150212',1003)
,(2,'20150122',2004)
,(2,'20150202',205)
,(2,'20160112',41020)
,(2,'20160212',11200)
,(2,'20140122',201)
,(2,'20140202',20)
SELECT ID as [Cust Ref]
, SUM(CASE WHEN Date_t = dateadd(MM,-1,getdate()) THEN Amount ELSE 0 END) as [Total LAST Month]
, SUM(CASE WHEN Date_t = getdate() THEN Amount ELSE 0 END) as [Total This Month]
FROM @temp
GROUP BY ID -
Set variable date in a procedure with current month and previous month
Hi guys, I need to set two date range in one procedure. The date should be
@datefrom the third day of the current month
@dateto the seventh day of the current month
@datefrom-1 the third day of the previous month
@dateto-1 the seventh day of the previous month
format like @datefrom '2014-03-03' @dateto '2014-03-07'
@datefrom '2014-02-03' @dateto '2014-02-07'
The problem for me it's going to be the jump between the years...2014 to 2015...any advice?
ThanksDECLARE @FirstDayOfCurrentMonth DATE
SELECT @FirstDayOfCurrentMonth = DATEADD(MONTH, DATEDIFF(MONTH, '01/01/1900', Current_timeStamp), '01/01/1900')
SELECT
DATEADD(DAY, 2, @FirstDayOfCurrentMonth) As ThirdDayOfCurrentMonth
,DATEADD(DAY, 6, @FirstDayOfCurrentMonth) As SeventhDayOfCurrentMonth
,DATEADD(DAY, 2, DATEADD(MONTH, -1, @FirstDayOfCurrentMonth)) As ThirdDayOfPreviousMonth
,DATEADD(DAY, 6, DATEADD(MONTH, -1, @FirstDayOfCurrentMonth)) As SeventhDayOfPreviousMonth
OUTPUT
ThirdDayOfCurrentMonth SeventhDayOfCurrentMonth ThirdDayOfPreviousMonth SeventhDayOfPreviousMonth
2014-12-03 2014-12-07 2014-11-03 2014-11-07
Best Wishes, Arbi; Please vote if you find this posting was helpful or Mark it as answered.
Maybe you are looking for
-
I need to set up Profile Manager on a completely closed network that has no Internet access at all. I can sneaker-net files into the network if I need to. Profile Manager (and Lion Server in general) seems to need outside access to complete setup and
-
Style sheets no longer working
Style sheets created and used previously are no longer working (properly). What's up with that?
-
Thanks in advance. Any idea on this topic is valuable. Is there any Reader for this purpose? I search J2SE API, but I found nothing. Thank you.
-
After updating to latest version, Firefox won't open
I am running Windows 7. After updating to the latest version, Firefox won't open. I get a notice when I try to open Firefox saying "Couldn't load XPCOM. Is there a way I can undo the update so I can get Firefox to open. It's my favorite browser...I'm
-
I currently am still using Snow Leopard because when I updated to Lion I did not like how it changed many of my apps., and or they would not work. I am thinking of getting a Apple laptop which would run on a newer OS, so I was wondering if my Pages a