Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Complicated avarage Post Reply Post New Topic
Author Message
assafse
Newbie
Newbie


Joined: 03 Jun 2012
Online Status: Offline
Posts: 8
Quote assafse Replybullet Topic: Complicated avarage
     Posted: 03 Jun 2012 at 12:35am
Hey all,

I'm tryng to do an avarage on sales table.
The table is designed that I have months on the top (column) jan, feb... dec

and rows are devided by years
2010
2011
2012

I need to do an avarage for each year.
and for 2012 I counted the number of the month month(CurrentDate())
and will devide by it.

I have a problem using GridLabelAt when I'm trying to read lable '2012' from my table
I can't find the correct systax for it, this is my code:

if GridLabelAt(year({Sap_Crystal_Logistic;1.DocDate})=2012) then
(
GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("Jan"), CurrentSummaryIndex)+
GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("Feb"), CurrentSummaryIndex)+
GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("Mar"), CurrentSummaryIndex)+
GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("Apr"), CurrentSummaryIndex)+
GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("May"), CurrentSummaryIndex)+
GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("Jun"), CurrentSummaryIndex)+
GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("Jul"), CurrentSummaryIndex)+
GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("Aug"), CurrentSummaryIndex)+
GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("Sep"), CurrentSummaryIndex)+
GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("Oct"), CurrentSummaryIndex)+
GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("Nov"), CurrentSummaryIndex)+
GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("Dec"), CurrentSummaryIndex)
)
else 99999

Help me correct it please..
Also if you have a better method I would like to hear it.

Thanks,
Assaf
IP IP Logged
assafse
Newbie
Newbie


Joined: 03 Jun 2012
Online Status: Offline
Posts: 8
Quote assafse Replybullet Posted: 05 Jun 2012 at 1:49am
I have lines that I need to divide in the current month count.

Example:
2010 will be divided by 12 months
2011 will be divided by 12 months
Current year (2012) will be divided by 6 months because we are in June.

How can I do that formula?

In SQL I can do that:
(CASE when YEAR(T0.DocDate) = YEAR(GETDATE()) Then Month(GETDATE())
else '12'
END) AS 'CurDate',

Quantity/(CASE when YEAR(T0.DocDate) = YEAR(GETDATE()) Then Month(GETDATE())
else '12'
END) AS 'Avarage'

I can't do it in Crystal..

Can someone advise?
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