moleary77
August 7th, 2007, 12:44 PM
I have this formula that is supposed to calculate the YTD Charges and Units yet it's not working. I have 2 parameters that determine the dateranges of the report. @DATE which selects an entrydate or service date then the date range of dates based off that selection.....can someone help me figure out why this YTD doesn't work??
IF Year({@Max Selection Date}) = Year({@DATE}) AND {@DATE} <= {@Max Selection Date} THEN
{CLCHARGE.CHGAMOUNT}
ELSE 0
Crystal 8.5
SvB_NY
August 7th, 2007, 02:52 PM
Try this:
If {@DATE} in YearToDate Then {CLCHARGE.CHGAMOUNT} Else 0
moleary77
August 7th, 2007, 04:12 PM
I did that but in one example I have 8 units for the period and then YTD it's showing 3?? Wouldn't then be 11?
SvB_NY
August 7th, 2007, 10:25 PM
Well, that formula calculates only the YTD Charges.
To calculate your YTD Units, you need to create another formula.
Unfortunately, you haven't mentioned what kind of calculation you need to do here (sum, count or distinct count...).
In case if you need Sum({your_table.Units}) where {@DATE} in YearToDate, your formula will be a similar one, let's call it @YTD_Units:
If {@DATE} in YearToDate Then {your_table.Units} Else 0
--------------------------------------------------------
If you want to count({your_table.Units}) where {@DATE} in YearToDate, your {@YTD_Units} will be the next one:
If {@DATE} in YearToDate Then 1 Else 0
If you need to calculate distinct count({your_table.Units})
then you will need to do 1 more step, to create a running total:
for filed to summarize select {your_table.Units};
set the type of distinct count;
For 'Evaluate' check the 'Use a formula' and enter:
{@YTD_Units}=1
Reset it 'On a change of group' if you need.
Is this helpfull?
:wave: