Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
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
Medium Priority
562 Views
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
Question by:bjennings
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 2
• 2

LVL 101

Accepted Solution

mlmcc earned 2000 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
else
{?Yesterday}

mlmcc

0

Author Comment

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 101

Expert Comment

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 35

Expert Comment

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

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

## Featured Post

Question has a verified solution.

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

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…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
###### Suggested Courses
Course of the Month9 days, 12 hours left to enroll