Joined: 19 Jan 2012
Online Status: Offline
Posts: 2
Topic: Lookup Formula? Posted: 19 Jan 2012 at 6:32am
Hi
I have a subreport that is working off an excel database, the excel "database" is actually a table with 2 columns for the sake of arguments lets call it
Date and Stock Price
In my report I want to have a table like this
Date Stock Price
This Month
1 Month Ago
6 Months Ago
12 Months Ago
24 Months Ago
Launch
I have set up formulas to pull the relative dates from my database for the left most column, using formulas, so I have 6 formula "This month", "This Month -1", "this Month -6" etc. Now I want someway so that I can pull the equivalent stock price corresponding to the displayed date for the Stock Price Column
If this where excell I would do a vlookup but I cant seem to find an answer anywhere on how to do the equivalent thing in Crystal Reports 2008.
Joined: 13 Jun 2011
Online Status: Offline
Posts: 475
Posted: 19 Jan 2012 at 8:26am
i assume that
Date
This Month
1 Month Ago
6 Months Ago
12 Months Ago
24 Months Ago
is a formula like {@Date}
if table.date in dateadd("m", + 1,currentdate) to dateadd("m", +6,currentdate)then "1 Month Ago" else
if table.date in dateadd("m", + 6,currentdate) to dateadd("m", +12,currentdate)then "6 Months Ago"
etc...
then you grouped on this formula
create another formula for Stock Price like
sum(table.stockprice, {@Date})
Joined: 19 Jan 2012
Online Status: Offline
Posts: 2
Posted: 19 Jan 2012 at 11:13pm
Well My table of dates and stock price only has one value for each month so for the last day in every month there is an entry.
I didnt think about writing a complex formula like that, I just have 6 formula
This Month = Maximum(table.date) = 31/12/11
This Month-1 = DateAdd('m',-1,{@This Month}) = 30/11/11
This Month-6 = DateAdd('m',-6,{@This Month}) = 30/06/11
etc
So I tried these two formula
sum(table.stockprice,table.date,{@This Month})
Thinking this was kind of
sum stockprice if date = {@This Month}
But I get an Error it highlights teh {@This Month} and says "Group Condition Must be a string" I tried using totext and that didnt work.
I also tried sum(table.stockprice,{@ThisMonth})
Then it highlights @ThisMonth and says "This field cannot be used as a group condition field"
if anyone can help me along with this, or even talk me through how i might combine all this into just 2 formula like kostya seemed to be hinting at, that would be great.
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