| Author |
Message |
VB001
Newbie
Joined: 07 Feb 2010
Location: United States
Online Status: Offline
Posts: 6
|

Topic: Help in writing a formula to calculate YTD Posted: 08 Feb 2010 at 8:15am |
|
Hello Guys,
I am a newbie and stuck on this problem of getting YTD in my report. My report has the following fields:
<Employee> <Title> <date> <Other related fields> <Leaves> <YTD Leaves>
Fields on this report are grouped by the Employee field. The
leave field basically captures the category of the leave i.e. if it was
a sick leave or a scheduled leave etc. I want to the calculate the
total number of leaves taken till date irrespective of category in the
<YTD> column. So, ideally I would want the column to get updated
automatically as the new data for the current date is added and to not change if there is a filter put on the Date field.
I know, I will have to use a formula but am not sure where to start, so please help me out here..
Any help is highly appreciated.
Thanks,
|
|
Vaibhav
|
IP Logged |
|
|
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|

Posted: 08 Feb 2010 at 8:33am |
Do you mean you just need a running count of rows if the LEAVES field is NOT NULL?
Create a Running Total
Name=EmployeeYTD
Field to Summarize=Leaves
Type of Summary=Count
Evaluate=For each record (unless you need somthing other than NOT NULL evaluated here)
Reset=On Change of Group (select employee group level)
Place this on your detail section to see a row by row count or the group footer for the emplee total
|
IP Logged |
|
VB001
Newbie
Joined: 07 Feb 2010
Location: United States
Online Status: Offline
Posts: 6
|

Posted: 08 Feb 2010 at 10:33am |
|
Thanks for replying. However, this is what I am trying to achieve. I wrote this formula for YTD. Its working, however it is not taking into account the groups. i.e. after placing this formula in the detail section of my report, I get YTD Leaves corresponding to each date, but it continues adding across the groups (Employees). Something like this:
Employee Date Leaves YTD A 2/1 1 1 2/2 1 2
B 2/1 1 3 (This should be 1) 2/2 1 4 (This should be 2)
Formula, I wrote is
Numbervar YTD; if {Date} in YearToDate then YTD := YTD + Leaves
I am not sure if I can achieve what I am trying to achieve using Running Total. Please suggest if there is a way to achieve the aforementioned either through a formula or Running Total.
Thanks,
|
|
Vaibhav
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|

Posted: 08 Feb 2010 at 10:55am |
You can do that as a variable formula or a RT, I just prefer Running Totals as I find them much easier to use.
If you continue doen your curretn variable path you need to add another variable to reset your counter at the group header level.
However I cannot tell exactly what your data is and what you are doing here...
1. Is your 'Leaves' value numeric and you are adding them togther and if so can it be greater than 1?
OR
is it just counting it when it is not NULL or " "?
2. Are you pulling in data that is not in the YTD? Edited by DBlank - 08 Feb 2010 at 10:58am
|
IP Logged |
|
VB001
Newbie
Joined: 07 Feb 2010
Location: United States
Online Status: Offline
Posts: 6
|

Posted: 08 Feb 2010 at 11:17am |
|
My "Leave" value is numeric. The field contains "1" if someone took a leave. So, basically carrying a cumulative addition. All, I need to get is a way to reset the value when it reaches the end of group. I am kind of bent on using this method since I need to calculate MTD too.
As far as your second question is concerned, I am not sure if I get it. My data is pretty simple. I have Employee name, date and the field "Leave" which will contain 1 if an employee took a leave. Something like this.
<Employee> <Date> <Leave> A 2/1/10 1 2/2/10 1 2/3/10 0
B 2/1/10 0 2/2/10 0 2/3/10 1
So, this basically means employee A was absent on 2/1/10 & 2/2/10 while B was absent on 2/3/10. I tried the Running Total method and its working especially resetting for each group. However, I am slightly bent on using the variable method since I need to calculate MTD too. I could add another group for Month and use RT for MTD, but I guess it will be easier for me to use the formula if I can somehow get a way to reset my variable at the end of each group.
Thanks,
|
|
Vaibhav
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|

Posted: 08 Feb 2010 at 11:25am |
You can add another RT for the MTD:
Name=EmployeeMTD
Field to Summarize=Leaves
Type of Summary=SUM
Evaluate=Use a formula
{Table.DateFeild} in Monthtodate
Reset=On Change of Group (select employee group level)
Place this on your detail section to see a row by row count or the group footer for the emplee total
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|

Posted: 08 Feb 2010 at 11:26am |
For YTD Running Total:
Name=EmployeeYTD
Field to Summarize=Leaves
Type of Summary=SUM
Evaluate=Use a formula
{Table.DateFeild} in Yeartodate
Reset=On Change of Group (select employee group level)
Edited by DBlank - 08 Feb 2010 at 11:27am
|
IP Logged |
|
VB001
Newbie
Joined: 07 Feb 2010
Location: United States
Online Status: Offline
Posts: 6
|

Posted: 08 Feb 2010 at 11:36am |
|
Thanks a lot, that's the easiest way to doing it.
However, I was wondering if there is a way of resetting the variable at the end of the group using the variable method?
Thanks for your help.
|
|
Vaibhav
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|

Posted: 08 Feb 2010 at 11:46am |
create another variable and place it in the group header
shared Numbervar YTD; YTD := 0
counter would be something like:
shared Numbervar YTD; YTD := YTD + (if {table.date} in YearToDate then {table.leaves})
|
IP Logged |
|
|
|