I am having a problem with my year to date and month to date totals. What I am trying to do is calculate the totals for the YTD and MTD. I have set up a date range parameter as well allowing the user to select a beginning date and an ending date.
The problem I have is in my record critera if I use the date range parameter In (BegDate) to (EndDate) the report will only return the data within the date range (as it should), however, The YTD Total is not correct.
When I use the use {@First of the year} to {EndDate} in the record critera it returns the entire year (as it should) but the Monthly totas calculate the yearly totals.
What date range needs to be in my record Critera for it to calculate the yearly total but display only the month set in my date range? Example: a user wants the data to display for the month of April as well as the total for the month of April but also need the YTD total.
Here is a sample of the code I am using. I am using Crystal Reports vs. 10.
Formula for Fist of the Month
cdate(year({?EndDate}), month({?EndDate}),1)
Formula for First of the Year
if year({?EndDate}) = 2005 then date(2005,01,01)
else
date(year({?EndDate}),1,1)
Formula for Month Start Date
date(year({@First of the Month}),month({@First of the Month}),1)
Formula for Count YTD
if {HSP_ACCOUNT.ADM_DATE_TIME} in {@First of the Year} to {?EndDate}
then DistinctCount ({PATIENT.PAT_MRN_ID})
Formula for MTD Total
if {HSP_ACCOUNT.ADM_DATE_TIME} in {@Month Start Date} to {?EndDate}
then DistinctCount ({PATIENT.PAT_MRN_ID})
The problem I have is in my record critera if I use the date range parameter In (BegDate) to (EndDate) the report will only return the data within the date range (as it should), however, The YTD Total is not correct.
When I use the use {@First of the year} to {EndDate} in the record critera it returns the entire year (as it should) but the Monthly totas calculate the yearly totals.
What date range needs to be in my record Critera for it to calculate the yearly total but display only the month set in my date range? Example: a user wants the data to display for the month of April as well as the total for the month of April but also need the YTD total.
Here is a sample of the code I am using. I am using Crystal Reports vs. 10.
Formula for Fist of the Month
cdate(year({?EndDate}), month({?EndDate}),1)
Formula for First of the Year
if year({?EndDate}) = 2005 then date(2005,01,01)
else
date(year({?EndDate}),1,1)
Formula for Month Start Date
date(year({@First of the Month}),month({@First of the Month}),1)
Formula for Count YTD
if {HSP_ACCOUNT.ADM_DATE_TIME} in {@First of the Year} to {?EndDate}
then DistinctCount ({PATIENT.PAT_MRN_ID})
Formula for MTD Total
if {HSP_ACCOUNT.ADM_DATE_TIME} in {@Month Start Date} to {?EndDate}
then DistinctCount ({PATIENT.PAT_MRN_ID})