lesleyag
Posts: 7
|
| Posted: 07/20/2004, 2:25 PM |
|
I have a grid populated from a view, which shows the number of Lost Time hours for each company and looks something like:
Company Lost Hrs
-----------------------------------
ABC 10
CDE 20
FGH 20
How do I add two formulae (one to calculate the total hrs and the other to show a percentage) so it looks like:
Company Lost Hrs
-------------------------------------
ABC 10 20%
CDE 20 40%
FGH 20 40%
-----------------------------------------
Total Hrs 50
I would truly appreciate an urgent response to this question
Cheers
Lesley
|
 |
 |
Benjamin Krajmalnik
|
| Posted: 07/20/2004, 2:57 PM |
|
Create a label and place it at the bottom of the table structure. Call it
ToalHours.
In the BeforeShow of the grid, call a DLookup action to sum the hours and
place it in that field.
On the row structure, add a label to hold the percent value. In the
BeforeShow event for the label, place the following code:
EventCaller.Value = (YourGridName.FIeldHoldingRowHours.Value /
YourGridName.TotalHours.Value ) * 100
EventCaller.Value = EventCaller.Value & "%"
"lesleyag" <lesleyag@forum.codecharge> wrote in message
news:640fd8dce22527@news.codecharge.com...
> I have a grid populated from a view, which shows the number of Lost Time
hours
> for each company and looks something like:
>
> Company Lost Hrs
> -----------------------------------
> ABC 10
> CDE 20
> FGH 20
>
> How do I add two formulae (one to calculate the total hrs and the other to
show
> a percentage) so it looks like:
>
> Company Lost Hrs
> -------------------------------------
> ABC 10 20%
> CDE 20 40%
> FGH 20 40%
> -----------------------------------------
> Total Hrs 50
>
> I would truly appreciate an urgent response to this question
>
> Cheers
> Lesley
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
DonB
|
| Posted: 07/20/2004, 6:33 PM |
|
I would start out with a query like this:
SELECT Company, SUM(LostHrs) AS 'Lost Hrs', LostHrs/(SELECT SUM(LostHrs)
FROM tblLostTime) AS 'Percent Lost' FROM tblLostTime GROUP BY Company;
and then utilize the "grid totals" described in the CCS help file.
The query above doesn't bother to consider NULL LostHrs values, I assume the
column to be "NOT NULL" by definition.
--
DonB
logging at http://www.gotodon.com/ccbth, and blogging at http://ccbth.gotodon.net
"lesleyag" <lesleyag@forum.codecharge> wrote in message
news:640fd8dce22527@news.codecharge.com...
> I have a grid populated from a view, which shows the number of Lost Time
hours
> for each company and looks something like:
>
> Company Lost Hrs
> -----------------------------------
> ABC 10
> CDE 20
> FGH 20
>
> How do I add two formulae (one to calculate the total hrs and the other to
show
> a percentage) so it looks like:
>
> Company Lost Hrs
> -------------------------------------
> ABC 10 20%
> CDE 20 40%
> FGH 20 40%
> -----------------------------------------
> Total Hrs 50
>
> I would truly appreciate an urgent response to this question
>
> Cheers
> Lesley
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
|