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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Turning data on its side 1

Status
Not open for further replies.

giggles7840

IS-IT--Management
Mar 8, 2002
219
US
cr xir/ xp

i have colums that i need to flip into rows. here is what i have.

Date Task Dayofweek
7/6/09 List A 2
7/7/09 Install B 3
7/7/09 List B 3
7/8/09 List C 4
7/9/09 Rewalk 5


What i need this to look like is

Mon Tues Wed Thur
List A Install B List C Rewalk
List B

I tried to set up a formula for each day of the week that said:
if dayofweek = 2 then Task
if dayofweek = 3 then Task
etc etc.

This only works for the first date listed and in each group then in goes blank for the rest of the week days. If there are multiple taks for a specific day then those each task needs to show up in the newly created column.

What is a good way to pull the data out each record line and display it horizontally.
 
Try a Crosstab - you'll find it under Insert on your menus.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 10 & 11.5 with Windows XP [yinyang]
 
Let's assume you are doing this within a group. This example will use only two days, but you can expand it to all days. Create a reset formula for the group header:

whileprintingrecords;
stringvar tues := "";
stringvar weds := "";

Then create a formula for the detail section {@accum}:

whileprintingrecords;
stringvar tues;
stringvar weds;
if dayofweek({table.date}) = 3 then
tues := tues + {table.task} + chr(13) else
tues := tues;
if dayofweek({table.date}) = 4 then
weds := weds + {table.task} + chr(13) else
weds := weds;

Then create one formula for each day of the week for the group footer:

//{@Tues}:
whileprintingrecords;
stringvar tues;

//{@Weds}:
whileprintingrecords;
stringvar weds;

Right click on each formula and format it to "can grow". Suppress the group header and details section. Drag the groupname into the group footer.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top