Solved

# Setting up a select statement based on whether a date falls in a Quarter

Posted on 2006-05-10
285 Views
I am trying to set up a report for an accountant.  The report is ran on a Quarterly basis because that is when sales tax is due.  The cost of the item is in the database as well as the date like 5/10/2006.  How do I set up a Parameter that just gives the accountant a choice of 1st Quarter, 2nd Quarter, 3rd Quarter, 4th Quarter.
0
Question by:cpursley1979

LVL 7

Expert Comment

Will the data for the report always be based on the current year, or will the accountant need to specify the year as well?
0

LVL 100

Expert Comment

When is the report run?  Will it be run at any time? or will it be run only at the start of a quarter so you need the previous quarter's data?

mlmcc

0

Author Comment

I belive the report will be ran at the start of the next quarter, and the previous quarter can be ran anytime after that
0

LVL 100

Accepted Solution

Something like this should work in the Select Expert will allow you to get the previous quarter at any time during the quarter.  If you want to be able to get at any previous quarter then something much more complex will be required.

if (CurrentDate in Calendar1stQuarter) then
{SaleDate} in Date(Year(CurrentDate)-1,10,1) to Date(Year(CurrentDate)-1,12,31)
else if (CurrentDate in Calendar2ndQuarter) then
{SaleDate} in Date(Year(CurrentDate),1,1) to Date(Year(CurrentDate),3,31)
else if (CurrentDate in Calendar3rdQuarter) then
{SaleDate} in Date(Year(CurrentDate),4,1) to Date(Year(CurrentDate),6,30)
else if (CurrentDate in Calendar4thQuarter) then
{SaleDate} in Date(Year(CurrentDate),7,1) to Date(Year(CurrentDate),9,30)

mlmcc

0

LVL 7

Assisted Solution

- To get data for the previous quarter based on todays date, create this record selection formula (pretty much the same as mmlc's):

switch
(
CurrentDate in Calendar1stQtr, {rptCounterListing.dtsaledate} in Date(Year(CurrentDate)-1,10,1) to Date(Year(CurrentDate)-1,12,31),
CurrentDate in Calendar2ndQtr, {rptCounterListing.dtsaledate} in Calendar1stQtr,
CurrentDate in Calendar3rdQtr, {rptCounterListing.dtsaledate} in Calendar2ndQtr,
CurrentDate in Calendar4thQtr, {rptCounterListing.dtsaledate} in Calendar3rdQtr
)

- To prompt the user to select a Quarter:
1.  Create a Parameter field called "Quarter", Prompt = "Please Select a quarter", Value Type = String, Discrete Values, Set Default values - "Qaurter 1", Quarter 2", etc.
2.  create this record selection formula

switch
(
{?Quarter} = "Quarter 1", {rptCounterListing.dtsaledate} in Calendar1stQtr,
{?Quarter} = "Quarter 2", {rptCounterListing.dtsaledate} in Calendar2ndQtr,
{?Quarter} = "Quarter 3", {rptCounterListing.dtsaledate} in Calendar3rdQtr,
{?Quarter} = "Quarter 4", {rptCounterListing.dtsaledate} in Date(Year(CurrentDate)-1,10,1) to Date(Year(CurrentDate)-1,12,31)
)
0

LVL 7

Expert Comment

oops - replace my date field with your's, forgot to clean that up :-)
0

LVL 100

Expert Comment

Glad i could help

mlmcc
0

## Join & Write a Comment Already a member? Login.

### Suggested Solutions

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…
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 …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

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

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

#### Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!