Calculated item divided by number of days in a month
Hello.
I'm trying to create a calculated item, that is supposed to represent a column member, divided by the number of days in a month that's selected from the dashboard prompt.
I know that I need an SQL function to get the number of days, but I don't think that you can use SQL functions when creating calculated items.
Is there a way to do this?
Looks like you are thinking too much
Use expression builder in the rpd and then just use available functions without 2nd thought.
if helps mark
Similar Messages
-
SSAS Tabular - return number of days in given month using month's start date?
Is there a way to return the number of days in a month by providing just the month date or month start date?
We have a time table, but it is at monthly (not daily) granularity.
So I can't just count rows between start/end of month.
I need to be able to divide by the number of days in a given month and can't seem to find a way to get number of days in that given month.
Thanks!Hi,
According to your description, you want to get the number of days in a month with the month's start date, right?
In this case, we can get the first day of next month using DateAdd function, and then use DateDiff function to calculate the number of days in this month. Here is a sample query for your reference.
WITH
MEMBER Measures.Today AS vba!Now()
member measures.FirstDayOfNextMonth as dateadd("m",1,Measures.Today)
member measures.daysnumber as datediff("d",Measures.Today,measures.FirstDayOfNextMonth)
select Measures.daysnumber on 0
from
[Adventure Works]
Reference
http://msdn.microsoft.com/en-us/library/hh510163.aspx
http://office.microsoft.com/client/helppreview14.aspx?AssetId=HV080007558&lcid=1033&NS=EXCEL%2EDEV&Version=14&tl=2&pid=CH080007543
http://office.microsoft.com/client/helppreview14.aspx?AssetId=HV080007559&lcid=1033&NS=EXCEL%2EDEV&Version=14&tl=2&pid=CH080007543
Regards,
Charlie Liao
TechNet Community Support -
Number of days in a month - 0CALDAY
Hi,
I have a query where I am calculating the average daily sales for each month. For this I need to know the number of days in each month. How can I do this? For instance, it should give 31 for Jan, 28/29 for Feb, 31 for Mar and so on. I am using OCALMONTH as the input variable.
Thanks for your help.
UdayHi Uday,
I have a few modifications in the code
Data: xdate type d,
ip_year(4) type N,
ip_month(2) type N.
Types : Begin of ty_month_days,
month(2) type N,
days(2) type N,
End of ty_month_days.
Data : it_month_days type ty_month_days occurs 0 with header line.
ip_year = 2006.
ip_month = 01.
do 12 times.
CONCATENATE ip_year ip_month '01' INTO xdate.
xdate = xdate + 33. "this date is in the next month
xdate+6(2) = '01'. "first day of next month
xdate = xdate - 1. "last day of xmonth
it_month_days-month = xdate+4(2). "number of days of xmonth.
it_month_days-days = xdate+6(2).
append it_month_days.
ip_month = ip_month + 1.
enddo.
This code stores Month and No. of days in the internal table it_month_days.
You can access this internal table for your calculations
This should help.
Regards,
Praveen.
Message was edited by: praveen mathew -
Calculate the number of days in a month
I need to do a calculation in my query based upon the number of days in the month. The report is broken down by cal year / month.
Is there an easy way of identifying these values in the query?
Regards.Hi,
This can be done by writing an user exit code to determine the number of days in the month.
Sample Code :
<
CHECK i_step = 2.
READ TABLE i_t_var_range WITH KEY vnam = 'XXXX'
INTO loc_var_range.
IF sy-subrc EQ 0.
beg_date(6) = loc_var_range-low(6).
end_date(6) = loc_var_range-low(6).
beg_date+6(2) = '01'.
end_date+6(2) = '01'.
ADD 1 TO end_date+4(2).
IF end_date+4(2) = '13'.
end_date+4(2) = '01'.
ADD 1 TO end_date(4).
ENDIF.
no_days = end_date - beg_date.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
l_s_range-low = no_days.
APPEND l_s_range TO e_t_range.
ENDIF.
>
Hope this helps..
Thanks & Regards,
Pradeep -
I want to get number of days in the month I've chosen from Timeline slicer.
I want to get number of days in the month
I've chosen from Timeline slicer,
does anyone know how to do?
The problem I want to solve is to divide
the number of customer visits as a salesman
made during a month by the number of
days in the month.Excel 2013 Pro Plus with PowerPivot.
Count working days per month
considering weekends and holidays.
With help from book:
"Building Data Models with PowerPivot"
by Alberto Ferrari and Marco Russo.
Easy. Not.
http://www.mediafire.com/view/rw78t1y3bg8vm0c/04_10_15.xlsx -
How To Split One Record into 30 Records(Number of days in a Month)
Hi Experts,
we are getting the montly(yearmonth) Forecast data from flat file we need to generate the report which shows the daily Forecast data,
For example for the month of June Forecast we have 150EA.
Flat file data is like this
0calday Qty
201006 150
we need to show the report like datawise
Calday Forecast qty
20100601 5
20100602 5
20100603 5
20100604 5
20100605 5
20100606 5
20100630 5
its like month forecast / Number of days in a month.
we can achive these in two ways as per my knowledge
1. At the time loading data
2. Reporting level
Which is the best way
how can we achive this.
Thanks
ChandraHey. There was a similar posting I gave a suggestion on a while back. Here is the link...
Re: Spliting records into cube
As far as the correct time of doing this, I would definitely do this at the time of data load and not time of reporting.
Hope you find it helpful.
Thanks -
Find number of days in current month
Hi Folks ,
I needed some help in knowing the number of days in any month ... I need to develop an application which will be triggering a mail with an excel attachment at the end of every month ...after populating the excel sheet from an Oracle database ..
Kindly help...
Thx..Thx a lot for your immediate reply .. I tried using
the calender class. But for my application .. i need
to automate this process by sending a mail every last
day of the month... but i am finding it a bit
difficult to really automate setting the current
month to the Timer class
Timer timer;
public Reminder ( int seconds ) {
timer = new Timer ( ) ;
timer.schedule( new RemindTask ( ), seconds*1000
000 ) ;
}The Calendar class is still the best solution IMHO. -
Restrict Data Input in an Input Schedule for a particular number of days in a Month
Hi All,
I want to restrict data save in Input Schedule for any particular number of days in a month. BRAD will select number of days for the that particular month and data input for that duration should be disabled.
Duration will be dynamic and will be decided by BRAD.
Basically this is a requirement of BPF, but I have thought of doing in this manner.
Regards,
MayankHi Vadim
I saw your this solution:
Dim epm As New FPMXLClient.EPMAddInAutomation
Dim blnMySave As Boolean
Public Function BEFORE_SAVE() As Boolean
If blnMySave Then
BEFORE_SAVE = True
Else
MsgBox "Please use button on the worksheet!"
BEFORE_SAVE = False
End If
End Function
It seems as if this may help me, but can you please guide me how to trigger this function for a change of value in any particular cell, in an input form. -
User Exit Variable for Calculating number of days in a month
I need a query to calulate the number of days in a particular month upto the current date. For example if i give 26 Feb it should reutrn 25, if i enter 30march it should return 29 for any specific year. I have gone through some posts and understood that i need to create a formula variable (under calculated KF's) and then go to CMOD, create a project, then enancement Assignment RSAP0001 then EXIT_SAPLRSAP_001 and include a code in INCLUDE ZXRSAU01. But i have any clue of coding. Could someone give me the entire code and how to connect it to the formula variable KF in created. The technical name of the key figure is ZMDAYS. If i have made any mistakes or if there is another eaier alternative please let me know. I thankyou all for the help.
Hi Uday,
I have a few modifications in the code
Data: xdate type d,
ip_year(4) type N,
ip_month(2) type N.
Types : Begin of ty_month_days,
month(2) type N,
days(2) type N,
End of ty_month_days.
Data : it_month_days type ty_month_days occurs 0 with header line.
ip_year = 2006.
ip_month = 01.
do 12 times.
CONCATENATE ip_year ip_month '01' INTO xdate.
xdate = xdate + 33. "this date is in the next month
xdate+6(2) = '01'. "first day of next month
xdate = xdate - 1. "last day of xmonth
it_month_days-month = xdate+4(2). "number of days of xmonth.
it_month_days-days = xdate+6(2).
append it_month_days.
ip_month = ip_month + 1.
enddo.
This code stores Month and No. of days in the internal table it_month_days.
You can access this internal table for your calculations
This should help.
Regards,
Praveen.
Message was edited by: praveen mathew -
I want to get this result in BEX. Please let me know how to get this. The result rows are shown below
Month Sales No of days in
ZCMNTH $8000
ZCMNTH-1 $7500
ZCMNTH-2 $5000
A sample of how the values should appear
Month Sales No of days
11/2005 $8000 30
10/2005 $7500 31
09/2005 $5000 30
08/2005 $9700 31
07/2005 $9850 31
So at query time how do I get the values for the number of days?
Thanks for help
RamGopalakrishna -
I just ran across the same problem. Instead of using the RSR00002 enhancement I used the BADI implementation. I found it easier to understand and I think it will be easier to maintain. I couln't find a lot of good documentation (HOW TO... Use variable time references in currency conversions was helpful though) about how to do it so here is how I did it.
1.In SE19 create an implementation based on rsr_olap_badi
2.Tell it which infoprovider(s) to look for under Defined Filters. (You can use wildcards here if you want)
3.Click on the Interface Tab and double click on the implementing class.
4. Define attribute on the Attributes tab. Characteristics must start with P_CHA and key figures must start with P_KYF ex. P_CHA_0CALMONTH2, P_CHA_0CALMONTH, P_KYF_ZNUMDAYS all must have type I.
5. In methods tab double click the define method. Here is where you tell it which characteristics and key figures to look for. Here is an example.
DATA: l_s_chanm TYPE rrke_s_chanm,
l_kyfnm TYPE rsd_kyfnm.
FIELD-SYMBOLS:
<l_s_chanm> TYPE rrke_s_chanm.
CASE i_s_rkb1d-infocube.
WHEN 'YOUR_CUBE_TECHNICAL_NAME_GOES_HERE'.
characteristics
l_s_chanm-chanm = '0CALMONTH2'.
l_s_chanm-mode = rrke_c_mode-read.
APPEND l_s_chanm TO c_t_chanm.
l_s_chanm-chanm = '0CALYEAR'.
L_S_CHANM-MODE = RRKE_C_MODE-READ.
APPEND L_S_CHANM TO C_T_CHANM.
key figure
l_kyfnm = 'ZNUMDAYS'.
APPEND l_kyfnm TO c_t_kyfnm.
ENDCASE.
ENDMETHOD. "if_ex_rsr_olap_badi~define
6. Double click on the compute method. Here is where you will populate the key figure. Here is an example. I had to wirte a function module because we only wanted work days versus all days of the month. But you get the idea.
METHOD IF_EX_RSR_OLAP_BADI~COMPUTE .
FIELD-SYMBOLS: <L_YEAR> TYPE ANY,
<L_MONTH> TYPE ANY,
<L_WORKDAYS> TYPE ANY.
if P_CHA_0CALYEAR <> 0 AND P_CHA_0CALMONTH2 <> 0.
assign: component P_CHA_0CALYEAR of structure C_S_DATA to <l_YEAR>,
COMPONENT P_CHA_0CALMONTH2 OF STRUCTURE C_S_DATA TO <L_MONTH>,
COMPONENT P_KYF_ZNUMDAYS OF STRUCTURE C_S_DATA TO <L_WORKDAYS>
CALL FUNCTION 'Z_SELECT_FACTDAYS_FOR_PERIOD'
EXPORTING
I_MONTH = <L_MONTH>
I_YEAR = <L_YEAR>
I_FISYRVAR = I_FISYRVAR
IMPORTING
E_WORK_DAYS = <L_WORKDAYS>.
endif.
ENDMETHOD. "IF_EX_RSR_OLAP_BADI~COMPUTE
That is it, if you included the correct fields in the attributes and the correct infoprovider in step 2. When you use those fields in a query it will populate znumdays with your calculation. -
FM to get the number of days in Year,month and days by giving number of day
Hi ALL,
This is quit differnt.
I need to give input the 'start date' and the 'number of days' and get the total days from the start date in year,month and day format.
for example.
start date :01.01.2009
number of days as 32
then i should get
years:0
months :1
days :1
Pleas help me out.hi Anusha,
first u pass the date and the days to the following fm you will get the result date....
data:date type sy-datum,
r_date(10) type c.
date = sy-datum.
CALL FUNCTION 'CALCULATE_DATE'
EXPORTING
DAYS = '32'
MONTHS = '0'
START_DATE = date
IMPORTING
RESULT_DATE = r_date
write:/ r_date.
then you need to pass the result date and the date to the following fm to get the required output...
CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'
EXPORTING
date1 = r_date
date2 = date
IMPORTING
years = v_years
months = v_months
days = v_days
EXCEPTIONS
invalid_dates_specified = 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.
here u will get the difference in days, months and year...
i hope u wil get help from this...
regards
Ashu Singh -
How to get the number of days of a month belonging to a date interval
Hi, i am getting mad around a problem, i have 2 dates and a month, i wanto to retrieve the number of days belonging to the month that are in the interval.
eg:
month january 2011 . begin_date = 11/JAN/2011, END_DATE 30/MAY/2011 result is 21
month january 2011 . begin_date = 11/DEC/2010, END_DATE 10/JAN/2011 result 10
month january 2011 .begin_date = 02/FEB/2011 , END_DATE 25/may/2011 result 0
month january 2011. begin_date = 03/JAN/2011 , END DATE 05/JAN/2011 result 3
and so on ...
i appreciate any suggestion
thank you
AndreaOh, I didnt see your result.
SQL> with t as
2 (select to_date('11/01/11','dd/mm/yy') from_dt,
3 to_date('30/05/11','dd/mm/yy') to_dt,
4 'Jan-11' mnth from dual
5 union all
6 select to_date('11/12/10','dd/mm/yy') from_dt,
7 to_date('10/01/11','dd/mm/yy') to_dt,
8 'Jan-11' mnth from dual
9 union all
10 select to_date('02/02/11','dd/mm/yy') from_dt,
11 to_date('25/05/11','dd/mm/yy') to_dt,
12 'Jan-11' mnth from dual
13 union all
14 select to_date('03/01/11','dd/mm/yy') from_dt,
15 to_date('05/01/11','dd/mm/yy') to_dt,
16 'Jan-11' mnth from dual
17 )
18 select from_dt,to_dt,mnth,
19 greatest(
20 least(last_day(to_date(mnth,'Mon-yy')),to_dt)
21 -
22 greatest(to_date(mnth,'Mon-yy'),from_dt)+1
23 ,0) cnt
24 from t;
FROM_DT TO_DT MNTH CNT
11-JAN-11 30-MAY-11 Jan-11 21
11-DEC-10 10-JAN-11 Jan-11 10
02-FEB-11 25-MAY-11 Jan-11 0
03-JAN-11 05-JAN-11 Jan-11 3 -
How to get the number of days in a month?
hi all
is there any way to get the number of days in a given month with a given year? for instance, if year is 2004 and the month is July or February, how can i get the number of days? thanks.Gee, I don't know ... Maybe this:
Calendar cal = Calendar.newInstance();
cal.set(Calendar.YEAR, 2004);
cal.set(Calendar.MONTH, Calendar.FEBUARY);
System.out.println("max days in month: " + cal.getActualMaximum(Calendar.DAY_OF_MONTH));
Do you not bother reading what people have already posted? Read the API docs on the Calendar class. -
Number of days in current month
Hi all,
I have a reporting situation, where I need to calculate the total
number of days in the currrent month based on system date/calender date. Do we have a standard function to return this value? Or any
variable? Or if you have done something similar, please let me know.
This is what I need. If today is July 28, then I need the value 31 to be returned. If its February, 28 or 29 dependinng on whether its leap year or not. I want to use this value to calculate other values.
Any help appreciated Guys !!!LAST_DAY_IN_PERIOD_GET should get you started..
Good Luck -
Calculating given occurance of a given day in every month
Hi,
I'm using oracle 10.2.0.1.0 and forms 6i.
I have inputs like frequency, day and start date.
Suppose
Start Date : 12-03-2011
Day : Saturday
Frequency : 2
What i want to do is, i want to calculate 2nd occurance of saturday(2nd Saturday), in every month, starting from the given date, till the end of the year.
The given start date, is anyway the 2nd occurance of saturday in March.
So now in april -- its is 09-04-2011
May -- 14-05-2011
June -- 11-06-2011
Is there a way to calculate like this?
Please help
ThanksHi,
Another way is to use the NEXT_DAY function, like this:
WITH parameters AS
SELECT DATE '2011-03-12' AS start_date
, 'SATURDAY' AS week_day
, 2 AS week_num -- This isn't really a frequency
FROM dual
, all_dates AS
SELECT start_date
, NEXT_DAY ( ADD_MONTHS ( TRUNC (start_date, 'MONTH')
, LEVEL - 1
) + (7 * week_num)
- 8
, week_day
) AS a_date
FROM parameters
CONNECT BY LEVEL <= 12
SELECT a_date
FROM all_dates
WHERE a_date >= start_date
AND TRUNC (a_date, 'YEAR') = TRUNC (start_date, 'YEAR')
ORDER BY a_date
;If you're doing this in Oracle Forms, then you don't need a sub-query like parameters. You can pass the parameters in PL/SQL variables, and use dual as the base table in all_dates (or use a PL/SQL loop).
The calculation of a_date works like this:
First, we find the beginning of the month.
Then, we add wekk_num weeks to that. For example, if week_num=2, that will give us the beginning of the 3rd week.
We're interested in the week before that, so we subtract 7, and we also subtract another 1 because NEXT_DAY always returns a date after (not the same as) its 1st argument.
Unfortunately, NEXT_DAY is always dependent on NLS_LANGUAGE. If you specify 'Saturday', but that day is called 'Lördag' in your NLS language, you'll get an error. If that's a possibility, then you can change the first sub-query like this:
WITH parameters AS
SELECT DATE '2011-03-12' AS start_date
, TO_CHAR ( DATE '2011-04-02' -- or any Saturday
, 'DAY'
) AS week_day
, 2 AS week_num
FROM dual
) ...Instead of April 2, 2011, you can you any Saturday you want; just be sure it's a Saturday.
Maybe you are looking for
-
Mass Maintain entries in tcode OKB9
Hi, How to maintain entries in OKB9 - Default Account Assignment... We want to maintain the entries as per Business Area / valuation area against respective Cost Element... We have approx 500 Cost Element and approx 40 Business Areas....and it's very
-
I just got a new IPOD NANO and when I charge it up it displays Chinese characters and my computer doesn't seem to recognize it. Ive been through the "5" steps without success....anyone have any ideas how to get this thing back to English and to link
-
Not crazy about the mouse wheel now zooming the sequence view if I put the pointer over the horizontal scroll bar. The sequence scrolls pretty slow with the mouse anywhere else. In previous versions, putting the pointer over the horizontal scroll b
-
I have the disk for the 09' iWork pages keynote and numbers. But is the a new updated disk with 11' or 12'?
-
Mail will not run after MBP migration to MBP Retina
I did a migration from a late 2009 MacBook Pro to a new Retina MacBook Pro and everything seems to have transfered over EXCEPT for Mail. I can't get the app to behave properly. When I first launched Mail I was prompted to add a mail account. If I hit