Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crosstab Column Sort - Need Month Columns to Sort Based on Parameter

Status
Not open for further replies.

crogers111

Technical User
Jan 23, 2004
158
US
CR XI
SQL

I have a report that prompts the user for a BegDate and EndDate which are parameters in a Stored Procedure which is the data source.

I have a Crosstab in the Report Footer with the following:

Rows:
@Year

Columns:
@MonthName

These formulas are:
@Year
totext(Year({Table.Date}),0,"")

@MonthName
MonthName({@MonthNumber}, True)

@MonthNumber
month({Table.Date})

PROBLEM:

I need the Crosstab Columns to be sorted based on the BegDate entered by the user. i.e. If the user inputs 7/1/2008 for the BegDate, I need the Crosstab Column 1 to be July. If the user enters 1/1/2009 for the BegDate, then I need January to be Column 1 of the Crosstab.



How do I sort the columns so that they begin with the month of the BegDate entered by the user ?





 
Use a month formula like this as the column in the crosstab:

month(dateadd("m",-month({@BegDate})+1,{table.date}))

In the crosstab expert, while this formula is selected, go to group options->options tab->customize name->use a formula->x+2 and enter:

monthname(month({table.date}),true)

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top