Author |
Message |
jnnpvan
Newbie
Joined: 03 Aug 2012
Location: Canada
Online Status: Offline
Posts: 19
|
Topic: paremeters for month and year Posted: 07 Aug 2012 at 10:49am |
I am working on a report and need to view the report by month and year.
The idea is:
- when the user wants to view a report by a month, just select the month from a parameter.
- when the user wants to view a report by a year, just select the year from a parameter.
How can I set this parameter in Crystal Report 2011 ?
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|
Posted: 07 Aug 2012 at 10:59am |
1 option...
you can add 2 params
1 called 'Type' as string for that has 'month' and 'year' as the 2 options
the other as a date field
do you mean they enter a date and you want
({?type}='month' and year({table.date})=year({?date}) and month({table.date})=month({?date}))
or
({?type}='year' and year({table.date})=year({?date}))
|
IP Logged |
|
jnnpvan
Newbie
Joined: 03 Aug 2012
Location: Canada
Online Status: Offline
Posts: 19
|
Posted: 07 Aug 2012 at 12:18pm |
Thanks,
I tried it, but when I run the report, it didn't link the correct parameter.
For example:
I type month is 1
year is 2011
but the data didn't run in January 2011.
What I need to set more in Crystal Report?
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|
Posted: 08 Aug 2012 at 4:11am |
I was recommending you create 1 paramter that is a string with static LOV of the values
Month
Year
the next parameter would be of a date type and allow the user to enter any date. you then use either the year and month or only the year fromt hat entered value.
You can go the direction of entrering month numbers and year numbers but I think it makes it more complicated and less clean. One down side to the date entry is users may be confused to why they are pick ing a 1 day(date) when they wanted a whole month or a whole year.
Edited by DBlank - 08 Aug 2012 at 4:17am
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|
Posted: 08 Aug 2012 at 4:26am |
Another approach closer to what I believe you had in mind would be
Create one parameter called 'Month'
set it to numeric
set it as a static LOV
set the values as 0 to 12
set the descriptions as the corresponding month names but make 0='All months'
Create another parameter called "Year"
set it as numeric.
set the minimum and maximum values to the years you want users to be able to enter. This will help avoid users leaving off the lead 2 characters or entering typos.
change the select expert to
({?month}=0 or {?month}=month({table.datefield})
and
{?Year}=year({table.datefield})
|
IP Logged |
|
jnnpvan
Newbie
Joined: 03 Aug 2012
Location: Canada
Online Status: Offline
Posts: 19
|
Posted: 08 Aug 2012 at 4:48am |
Hi,
Thanks for your help.
I used the second hint with created 2 seperate parameters "month" and "year"
I got it, but one thing, when I set it to numeric, the number to display on the Range view report has the format like this:
This is my formula:
'Report view in ' + totext({?month}) + ' / ' + to text({?year})
and the otuput is:
Report view in 1.00 / 2011.00
It mean Report view in January 2011,
How can I get a nice format of the month and yeat like this
Report view in 1 / 2011
Edited by jnnpvan - 08 Aug 2012 at 4:49am
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|
Posted: 08 Aug 2012 at 4:51am |
(if {?month}=0 then 'All of ' else monthname({?month})) + totext({?Year},0,'')
Edit: oops ... I see you wanted the number not the month name.
Not sure what you want for no month selection (e.g. 0) ...
(if {?month}<>0 then totext({?month},0,'')+ ' / ' else '') + totext({?Year},0,'')
Edited by DBlank - 08 Aug 2012 at 4:56am
|
IP Logged |
|
jnnpvan
Newbie
Joined: 03 Aug 2012
Location: Canada
Online Status: Offline
Posts: 19
|
Posted: 08 Aug 2012 at 5:07am |
Thank you DBlank.
One thing I want to do like to view the report with a quarter, 4 months, 6 months.
How can I set the parameter together with the parameter every month and one year that I just done ?
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|
Posted: 08 Aug 2012 at 5:27am |
you can create another param for the quarter selection by using datepart()
(?quarter)=0 or ?quarter=datepart('q',table.datefield)
|
IP Logged |
|
jnnpvan
Newbie
Joined: 03 Aug 2012
Location: Canada
Online Status: Offline
Posts: 19
|
Posted: 08 Aug 2012 at 6:56am |
But I don't know how to combine with the quarter condition.
In Select Expert, I did:
( ( {?Month} = 0 ) or ( {?Month} = month({Command.createddatetime}) ) ) and ( ({?Year} = 0 ) or ({?Year} = year({Command.createddatetime}))
and in formula I did:
'Working Hours In ' + (if {?month}= 0 then 'year' else if {?Month} <> 0 then monthname({?month}) else if {?Quarter} = 0 then 'year' else if {?Quarter} <> 0 then 'Quarter ' + totext({?Quarter}) + ' of ' ) + ' ' + totext({?Year},0,'')
But how can run when select Quarter, then the data only run with Quarter condition, not run with month and year condition?
|
IP Logged |
|
|