SequestTech

asked on

# Period to date and Year to date

I need to get the period to date as well as year to date charge amounts by a program.

I am using @ToDate to retrieve the data from SQL. I am not quite sure how my formulas should look. I created this formula for the period charges but it just brings back zeros

if date(Minimum ({TPr_ProcedureReimbursement;1.DateTrans},{@Group Program} )) in Cdate({?From Date}) to Cdate ({?@todate})

then Sum ({TPr_ProcedureReimbursement;1.Charges}, {@Group Program})

else 0

This is what I created for year to date

if date(Minimum ({TPr_ProcedureReimbursement;1.DateTrans}, {@Group Program})) in date(Year({?@todate})-1,1,1) to DateAdd('y',-1,{?@todate})

then Sum ({TPr_ProcedureReimbursement;1.Charges}, {@Group Program})

else 0

This is ignoring the date and jusr sums al charges by program

Any guidance would be appreciated.

I am using @ToDate to retrieve the data from SQL. I am not quite sure how my formulas should look. I created this formula for the period charges but it just brings back zeros

if date(Minimum ({TPr_ProcedureReimburseme

then Sum ({TPr_ProcedureReimburseme

else 0

This is what I created for year to date

if date(Minimum ({TPr_ProcedureReimburseme

then Sum ({TPr_ProcedureReimburseme

else 0

This is ignoring the date and jusr sums al charges by program

Any guidance would be appreciated.

Are you using a stored procedure or just reading tables directly in your report or ...? As mlmcc mentioned, the record selection in your report, or the WHERE in your stored procedure, needs to include the whole year (however you define that) for the YTD part.

As for your formulas, it depends on what {?From Date} and {?@todate} are, and what data the report is reading, but trying to use Minimum is probably at least part of the problem.

I'm guessing that {?From Date} and {?@todate} are the starting and ending dates for the period.

For the period formula:

The report will have to read data for the whole year to calculate the YTD total. That means that the minimum date for each {@Group Program} will probably be some time earlier in the year (before the current period), so the minimum date won't be between {?From Date} and {?@todate}, so you get 0 for the period formula.

For the YTD formula:

> This is ignoring the date and jusr sums al charges by program

That would normally be what you want, if the report is only reading the data for the current year (up to {?@todate}). If the report includes data after {?@todate}, the formula will be comparing the minimum date for each {@Group Program} to see if it falls in the year range, and if it does, it does a sum of _all_ of the records for the group.

Perhaps you're thinking that the date test in the if-else is applied to the Sum function. It is not. Sum ({field1}, {group field}) always returns the total for {field1} from every record in the group.

If you can have the record selection (or the WHERE in your stored procedure) limit the records to just the ones in whatever you consider to be the "year to date", then you can just do a simple summary of Charges to get the YTD total. If you need to include records with dates outside of the "year to date", you can use a formula similar to the one below for the period.

For the period total, create a formula like the following and do a summary for the group on that formula:

if Date({TPr_ProcedureReimbursement;1.DateTrans}) in

Cdate ({?From Date}) to Cdate ({?@todate}) then

{TPr_ProcedureReimbursement;1.Charges}

James

As for your formulas, it depends on what {?From Date} and {?@todate} are, and what data the report is reading, but trying to use Minimum is probably at least part of the problem.

I'm guessing that {?From Date} and {?@todate} are the starting and ending dates for the period.

For the period formula:

The report will have to read data for the whole year to calculate the YTD total. That means that the minimum date for each {@Group Program} will probably be some time earlier in the year (before the current period), so the minimum date won't be between {?From Date} and {?@todate}, so you get 0 for the period formula.

For the YTD formula:

> This is ignoring the date and jusr sums al charges by program

That would normally be what you want, if the report is only reading the data for the current year (up to {?@todate}). If the report includes data after {?@todate}, the formula will be comparing the minimum date for each {@Group Program} to see if it falls in the year range, and if it does, it does a sum of _all_ of the records for the group.

Perhaps you're thinking that the date test in the if-else is applied to the Sum function. It is not. Sum ({field1}, {group field}) always returns the total for {field1} from every record in the group.

If you can have the record selection (or the WHERE in your stored procedure) limit the records to just the ones in whatever you consider to be the "year to date", then you can just do a simple summary of Charges to get the YTD total. If you need to include records with dates outside of the "year to date", you can use a formula similar to the one below for the period.

For the period total, create a formula like the following and do a summary for the group on that formula:

if Date({TPr_ProcedureReimbur

Cdate ({?From Date}) to Cdate ({?@todate}) then

{TPr_ProcedureReimbursemen

James

ASKER

Don't close. I am just getting back to this report and i need to evaluate the answers that I receievd.

ASKER CERTIFIED SOLUTION

membership

Create an account to see this answer

Signing up is free. No credit card required.

This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.

Your selection formula should be

{TPr_ProcedureReimbursemen

{TPr_ProcedureReimbursemen

Why were you subtracting 1 from the year?

Are you tring to get last year's data?

Is ToDate a range?

mlmcc