Using a parameter field for specific date calculations:
Create a parameter: @currentperiodend
SalesCurrent: @currentbegin: (date)
if {invdth.idhdat} in {@currentbegin} to {?currentperiodend} {?currentperiodend}-day({?currentperiodend})+1
then {invdth.idhprc}
else 0
@priorbegin: (date/time)
dateadd("yyyy",-1,{@currentbegin})
SalesPrior:
if {invdth.idhdat} in {@priorbegin} to {@priorend}
@priorend: (date/time)
then {invdth.idhprc} dateadd("yyyy",-1,{?currentperiodend}+1)-1
else 0
Current Cost:
Currentperiodend: (parameter) {invdth.idhdat} in {@currentbegin} to {?currentperiodend}
Type: date
Prior Cost:
{invdth.idhdat} in {@priorbegin} to {@priorend