Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8524

Re: Daily average report

$
0
0

Hi,

 

 

 

A crosstab, as Brian suggests, is the ideal way to go about building such reports. Do note however, that it will skip any rows/columns that doesn't have any data in the database.

 

You don't want a crosstab that doesn't show the Weekday just because there aren't any appointments for that day for the next few weeks (very rare situation in my opinion).

 

 

 

It is still worth covering up for the not-so-obvious. You'll need to build a table in the database with a DateTime column that list all dates for perhaps the next two or more years and LEFT JOIN it to the existing ApptDateTime field. Throughout the report, wherever you've referenced the ApptDateTime field, replace that with the DateTime field from the new table.

 

 

 

Once you have the above sorted out, you have some more work before the Crosstab is ready. Here's what you need to do (Steps work only for CR 2008 or higher):

 

 

 

1) Add the record selection formula so that it gives the weekends a miss:

 

 

 

Not(datepart('w',{DateTimeField}) IN [1,7])

 

 

 

2) Create a formula called 'DayName' with this code:

 

 

 

datepart('w',{DateTimeField})

 

 

 

3) Insert the crosstab. Use the DateTime field as the Row and set it to the Print 'For each week' by clicking the options button

 

 

 

4) Use the 'DayName' field as the Column > Click Group Options > Options tab > Click 'Customize Group Name field' > Click the formula button beside 'Use a formula' and use this code:

 

 

 

WeekDayName(datepart('w',{DateTimeField}))

 

 

 

5) Use the PatientNumber field as the Summarized Field and change the Summary to 'Count'

 

 

 

6) Refresh the report and while in the Preview Mode, right-click the 'Total' Column > Select Column Grand Totals > Check 'Suppress Grand Totals'

 

 

 

7) Right-click column header for 'Friday' and select Calculated Member > Insert Column. A blank column with zero values is inserted

 

 

 

8) Right-click the blank header cell > Calculated Member > Edit Header Formula and type this:

 

"Average # Appts"

 

 

 

9) Next, Right-click one of the zero value cells in the newly added column > Calculated Member > Edit Calculation Formula and use this code:

 

local numbervar i;   

local numbervar avg;   

local numbervar cnt;  

for i := 0 to CurrentColumnIndex-1 do   

(   

    avg := avg + (GridValueAt(CurrentRowIndex, i, CurrentSummaryIndex);   

    cnt := cnt + 1;   

);   

avg/cnt;

 

 

 

Let me know how this goes.

 

 

 

-Abhilash


Viewing all articles
Browse latest Browse all 8524

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>