Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Help with Rows Quotient between years Post Reply Post New Topic
Author Message
assafse
Newbie
Newbie


Joined: 03 Jun 2012
Online Status: Offline
Posts: 8
Quote assafse Replybullet Topic: Help with Rows Quotient between years
     Posted: 21 Jun 2012 at 12:57am
I can't find a way to do a Quotient in a new column, like the example in the Table link.
Help with this table Table

Can someone advice?
FYI
I found a way to do it by column but not by row.
if (GridValueAt(CurrentRowIndex, currentcolumnindex-2, CurrentSummaryIndex)=0) then 0
Else
(GridValueAt(CurrentRowIndex, currentcolumnindex-1, CurrentSummaryIndex)/GridValueAt(CurrentRowIndex, currentcolumnindex-2, CurrentSummaryIndex)-1)*100
if I do this
if (GridValueAt(CurrentRowIndex-1 (or +1), currentcolumnindex, CurrentSummaryIndex)=0) then 0
it gives me an error : "Argument #1 of 'GridValueAt' is out of range"
If you have a better I will love to hear it.
Thanks,

Help with this table Table
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 21 Jun 2012 at 3:29am
on the first frow, there is not a row before, so the value is out of range...you should be able to get around this by using something like:
if currentrowindex = 1 then
  //do something
else
  //what you already have
 
 
this is just as a guess as I don't use grids, but it makes sense from a logic point-of-view.
 
HTH
IP IP Logged
assafse
Newbie
Newbie


Joined: 03 Jun 2012
Online Status: Offline
Posts: 8
Quote assafse Replybullet Posted: 02 Sep 2012 at 9:02pm
Thanks for your help,
I have another problem.
I'm doing the Quotient between years.
I have 3 rows per item
2010
2011
2012

There are some items that was sold only in 2012 so when I do this formula below it gives me out of range..
how can I tell it to ignore (or devide by 1) if the row doesnt exist?

If 2012 <> 0 then

(
If year(Gridlabelat("TOD_Master_sheet_For_Sap_Crystal_Logistic;1.DocDate", currentrowindex)) = ({@CurDate})
and (GridValueAt (CurrentRowIndex, currentcolumnindex+2, CurrentSummaryIndex)) <> 0

then
(GridValueAt (CurrentRowIndex, currentcolumnindex+2, CurrentSummaryIndex)) /


(

if   year(Gridlabelat("TOD_Master_sheet_For_Sap_Crystal_Logistic;1.DocDate", currentrowindex)) = ({@2011})
and (GridValueAt (CurrentRowIndex, currentcolumnindex+2, CurrentSummaryIndex)) = 0
then

0
else

(GridValueAt (CurrentRowIndex-1, currentcolumnindex+2, CurrentSummaryIndex))
)

else (

If year(Gridlabelat("TOD_Master_sheet_For_Sap_Crystal_Logistic;1.DocDate", currentrowindex)) = ({@2011})
and (GridValueAt (CurrentRowIndex, currentcolumnindex+2, CurrentSummaryIndex)) <> 0

then
(GridValueAt (CurrentRowIndex-1, currentcolumnindex+2, CurrentSummaryIndex))
year(Gridlabelat("TOD_Master_sheet_For_Sap_Crystal_Logistic;1.DocDate", currentrowindex)) = ({@2010})

else 0
)

)
else 0
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 04 Sep 2012 at 4:20am
I would check for a null value...at least that is my first thought.
 
If Not IsNull({table.field}) then (
...
)
 
HTH
IP IP Logged
assafse
Newbie
Newbie


Joined: 03 Jun 2012
Online Status: Offline
Posts: 8
Quote assafse Replybullet Posted: 04 Sep 2012 at 4:46am
Yes but ISNULL dont work for me, because I'm taking the year from the label
year(Gridlabelat("TOD_Master_sheet_For_Sap_Crystal_Logistic;1.DocDate", currentrowindex))

I can't add ISNULL to that..
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 04 Sep 2012 at 8:40am
then it would seem that you are going to have check the value in the cell, and if it is null or 0...
 
I don't know anything about grids, but in essence you are going to have to check that your divisor exists / is not zero before doing the math.
IP IP Logged
assafse
Newbie
Newbie


Joined: 03 Jun 2012
Online Status: Offline
Posts: 8
Quote assafse Replybullet Posted: 05 Sep 2012 at 5:41am
That's my problem... for some lines it doesn't exist.
How do I tell it to ignore or deide by something else if it does not exist?
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