Solved

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

Posted on 2009-04-09
5
551 Views
Last Modified: 2012-05-06
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
Comment
Question by:bjennings
  • 2
  • 2
5 Comments
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 24110294
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
 

Author Comment

by:bjennings
ID: 24112084
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
 
LVL 100

Expert Comment

by:mlmcc
ID: 24112310
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
 
LVL 34

Expert Comment

by:James0628
ID: 24113151
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
 

Author Closing Comment

by:bjennings
ID: 31568677
Thanks!  I can work with this formula!!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Next Full Week 4 76
Sporadic user accounts locking out - 2003 AD functional level 6 104
C# Crystal Reports 15 79
Crystal Reports Repeat Report Footer X amount of times 6 30
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now