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

When to use Cross Tab?

Status
Not open for further replies.

lucy76

Technical User
Aug 3, 2003
3
AU
We have received a report that the developer has written in Cross Tab it is to show an employees hours work. For example

Mon Tue Wed Thur Fri
John Smith 7.6 7.6 7.6 7.6 7.6
Jane Doe 5.6 5.6 5.6 7.6 5.0

I understand from the developer that because it is written using the cross tab we have to have these hours/mins in decimal as there is no way to convert them back to time.

Is Cross Tab the best way to write this report?
Couldn't it be written without the use of Cross Tab and therefore allow to conversion from decimal to time?

Thanks Lu
 
I think you should be able to convert the decimal version to hours and minutes. For your summary field in the crosstab, you would use the conversion formula instead of the current {@hoursworked} formula.

SynapseVampire has written an FAQ on this conversion, and the following adapts his formula to round seconds to minutes:

numbervar hrswrk := {@hoursworked};
numbervar hours;
numbervar mins;
stringvar hhmm;

hours := truncate(truncate(hrswrk/60)/60);
mins := round(remainder(truncate(hrswrk)/60,60));
hhmm := totext(hours, "0") + ":" + totext(mins, "00");
hhmm;

Since this is a text result, you would need to ensure that there was only one unique value per row/column and then choose Nth Most Frequent N = 1 for your summary operation. This also means you can't do further calculations, e.g., total for the week, using this formula. You could do a manual crosstab, though, and then you could add a different formula to get the total and convert it to hours:minutes format.

-LB
 
Thank you very much for that, it was very useful

Lucy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top