Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 566
  • Last Modified:

Crystal Reports - If your date based record select is null can you loop back until it is not null

Hello Everyone,

I am working on a sales report-subreport and have a problem when there are no sales for a specific date.
I have the following record select statement on the subreport:
 {mydate} = {?Yesterday}.
 ({?Yesterday} is the date of sales and that is passed through to the sub report.)  

I have a lot of calculations based on {mydate}, so when {?yesterday} falls on a Sat or Sunday (when there are no sales) none of my calculations work.  Is there a way on the sub report and loop backwards to the last date when there were sales?   Can I do this in the record select on the sub form?

Thanks,

Bill
0
bjennings
Asked:
bjennings
  • 2
  • 2
1 Solution
 
mlmccCommented:
Not really.  You could write a formula to change ?Yesterday to get Friday for Monday rather than Sunday.
You would then link the subreport on the formula rather than the parameter

It would be something like
If DayOfWeek({?Yesterday}) = 2 then
    DateAdd('d',-3,{?Yesterday})
else
   {?Yesterday}

mlmcc

0
 
bjenningsAuthor Commented:
Hello Mlmcc..This works good, but it just dawned on me that their are Holidays and days that we are closed so there would not be any sales records.  Is there a way to check say to see if there are any records for {mydate} and if not to keep going back a day until their are records?

Thanks,

Bill
0
 
mlmccCommented:
You could modify the formula to check for holidays but there is no way to then check if there are records for the given day.

mlmcc
0
 
James0628Commented:
The best option would be if you could change the formula to account for any days that you're closed.  If you can't do that, I can think of other possibilities, but none of them seem particularly good (efficient/easy/etc.).

 James
0
 
bjenningsAuthor Commented:
Thanks!  I can work with this formula!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now