Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Calculate Previous year MTD and Prevoius year YTD Post Reply Post New Topic
Author Message
krishreddy
Newbie
Newbie


Joined: 18 May 2012
Location: India
Online Status: Offline
Posts: 11
Quote krishreddy Replybullet Topic: Calculate Previous year MTD and Prevoius year YTD
     Posted: 07 Jan 2013 at 1:31am
Hi ,

I am building the sales details report by using the SAP R3 tables for 'MTD', 'YTD' , 'Prev year MTD', 'Prev year YTD'..

Here I am am writing the formulas like below

for YTD - I am giving date range like from date and to date.

for MTD- if month({VBRK.FKDAT})=month(maximum({?Date}) )then {@YTD Qty}

for Prev year MTD - if maximum({?Date}) in LastYearMTD Then {@YTD Qty} else 0

But I am getting '0' values for 'Prev year MTD' when I use the above formula.

Could you please suggest me how can I write formulas for 'Prev year MTD' and 'Prev year YTD'.
IP IP Logged
Sastry
Moderator
Moderator
Avatar

Joined: 16 Jul 2012
Online Status: Offline
Posts: 537
Quote Sastry Replybullet Posted: 07 Jan 2013 at 1:45am
HI

Try the following :

Prev Year MTD :

IF {?date} >=date(year({?Date})-1,Month({?Date}),01)
and
{?date} <= date(year({?Date})-1,Month({?Date}),day({?date}) Then
{@YTD Qty} else 0

Prev Year YTD :

IF {?date} >=date(year({?Date})-1,01,01)
and
{?date} <= date(year({?Date})-1,Month({?Date}),day({?date}) Then
{@YTD Qty} else 0


Thanks,
Sastry
IP IP Logged
krishreddy
Newbie
Newbie


Joined: 18 May 2012
Location: India
Online Status: Offline
Posts: 11
Quote krishreddy Replybullet Posted: 07 Jan 2013 at 5:25pm
Hi,

Thanks for Reply.
I wrote formulas like below
LY MTD:

IF {VBRK.FKDAT} in
date(year({@Max Date})-1,Month({@Max Date}),01)
to
date(year({@Max Date})-1,Month({@Max Date}),day({@Max Date})) Then {@YTD Qty} else 0

LY YTD:

IF {VBRK.FKDAT} in
date(year({@Min Date})-1,Month({@Min Date}),01)
to
date(year({@Max Date})-1,Month({@Max Date}),day({@Max Date})) Then {@YTD Qty} else 0

But its getting null values.

Could you please suggest me is there any mistakes in this formula.

Here {VBRK.FKDAT} date for mat is 01-12-2012
and date(year({@Min Date})-1,Month({@Min Date}),01) format is 11-12-01

how can I match this 2 different date formats.


Edited by krishreddy - 07 Jan 2013 at 5:38pm
IP IP Logged
Sastry
Moderator
Moderator
Avatar

Joined: 16 Jul 2012
Online Status: Offline
Posts: 537
Quote Sastry Replybullet Posted: 09 Jan 2013 at 12:21am
HI

Try with following conversion :

cdate(Totext(date(year({@Min Date})-1,Month({@Min Date}),01),"MM/dd/yyyy"))


Thanks,
Sastry
IP IP Logged
krishreddy
Newbie
Newbie


Joined: 18 May 2012
Location: India
Online Status: Offline
Posts: 11
Quote krishreddy Replybullet Posted: 24 Jan 2013 at 5:48pm
Hi Sastry,

Thanks for reply,

This formula also picking 0's only.

Could you please suggest me is there any other option for SAP R3 tables database fields.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum