8155de0e77456fd8b551baecb388696dc506c8e6
[kohadocs.git] / en / source / 11_reports.rst
1 .. include:: images.rst
2
3 Reports
4 =======
5
6 Reports in Koha are a way to gather data. Reports are used to generate
7 statistics, member lists, shelving lists, or any list of data in your
8 database.
9
10 -  *Get there:* More > Reports
11
12 `Custom Reports <#customreports>`__
13 -----------------------------------
14
15 Koha's data is stored in a MySQL database which means that librarians
16 can generate nearly any report they would like by either using the
17 `Guided Reports Wizard <#quidedreportwizard>`__ or writing their own
18 `SQL query <#reportfromsql>`__.
19
20 `Add Custom Report <#customreport>`__
21 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22
23 `Guided Report Wizard <#quidedreportwizard>`__
24 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
25
26 The guided report wizard will walk you through a six step process to
27 generate a report.
28
29 Step 1: Choose the module you want to report on. This will determine
30 what tables and fields are available for you to query.
31
32 'Report is public' should be left to the default of 'No' in most cases.
33 A report can be made public if you intend to allow access to it through
34 the JSON webservice interface. This is a system that can be used by
35 developers to make custom presentations of the data from the report, for
36 example displaying it using a graphing API. To learn more speak to your
37 local developer.
38
39 -  A public report is accessible via a URL that looks like this:
40    http://MYOPAC/cgi-bin/koha/svc/report?id=REPORTID
41
42 Chose Module for Report
43 |image881|
44
45     **Note**
46
47     If your system administrator has set up memcache on your server you
48     might see one more option for the Cache expiry. This is related to
49     your public reports. If you make the report public then it's
50     constantly running and will cause a large load on your system.
51     Setting this value prevents that.Cache expiry
52
53 Step 2: Choose a report type. For now, Tabular is the only option
54 available.
55
56 Report Type
57 |image882|
58
59 Step 3: Choose the fields you want in your report. You can select
60 multiple fields and add them all at once by using CTRL+Click on each
61 item you want to add before clicking the Add button.
62
63 Select database fields to query
64 |image883|
65
66 Step 4: Choose any limits you might want to apply to your report (such
67 as item types or branches). If you don't want to apply any limits,
68 simply click Next instead of making an option.
69
70 Choose limits
71 |image884|
72
73 Step 5: Perform math functions. If you don't want to do any
74 calculations, simply click Next instead of making an option.
75
76 Choose math functions
77 |image885|
78
79 Step 6: Choose data order. If you want the data to print out in the
80 order it's found in the database, simply click Finish.
81
82 Choose ordering
83 |image886|
84
85 When you are finished you will be presented with the SQL generated by
86 the report wizard. From here you can choose to save the report by
87 clicking 'Save' or copy the SQL and make edits to it by hand.
88
89 Custom Report Confirmation
90 |image887|
91
92 If you choose to save the report you will be asked to name your report,
93 sort it in to groups and subgroups and enter any notes regarding it.
94
95 Save custom report
96 |image888|
97
98 Once your report is saved it will appear on the 'Use Saved' page with
99 all other saved reports.
100
101 Saved Reports list
102 |image889|
103
104 From here you can make edits, run the report, or schedule a time to have
105 the report run. To find the report you created you can sort by any of
106 the columns by clicking the on the column header (creation date is the
107 best bet for finding the report you just added). You can also filter
108 your results using the filter menu on the left or use the tabs to find
109 reports based on your custom groups.
110
111 `Report from SQL <#reportfromsql>`__
112 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
113
114 In addition to the report wizard, you have the option to write your own
115 queries using SQL. To find reports written by other Koha users, visit
116 the Koha Wiki: http://wiki.koha-community.org/wiki/SQL_Reports_Library.
117 You can also find your database structure in
118 /installer/data/mysql/kohastructure.sql or online at:
119 `http://schema.koha-community.org <http://schema.koha-community.org/>`__.
120
121 To add your query, click the link to 'Create from SQL' on the main
122 reports module or the 'New report' button at the top of the 'Saved
123 reports' page.
124
125 New SQL Report
126 |image890|
127
128 Fill in the form presented
129
130 Create Report from SQL
131 |image891|
132
133 -  The 'Name' is what will appear on the Saved Reports page to help you
134    identify the report later. It will also be searchable using the
135    filters found the left of the Saved Reports page.
136
137 -  You can use the 'Report group' to organize your reports so that you
138    can easily filter reports by groups. Report groups are set in the
139    `REPORT\_GROUP <#reportgroup>`__ authorized value category or can be
140    added on the fly when creating the report by choosing the 'or create'
141    radio button.Report groups set up in the authorised value category
142    need to have unique authorised values and descriptions.
143
144    -  **Note**
145
146           If you're adding a report group on the fly, remember that you
147           code should be fewer than 10 characters and should not include
148           special characters or spaces.
149
150 -  You can use 'Report subgroup' to further organize your reports so
151    that you can easily filter reports by groups and subgroups. Report
152    subgroups are set in the `REPORT\_SUBGROUP <#reportsubgroup>`__
153    authorized value category or can be added on the fly when creating
154    the report by choosing the 'or create' radio button.  Report Subgroups
155    are set up with unique values in Authorised Value, and Description. 
156    The Description (OPAC) field needs to contain the authorised value for 
157    the Report Group that the Subgroup falls under.
158
159    Report subgroup
160    |image892|
161
162    -  **Note**
163
164           If you're adding a report subgroup on the fly, remember that
165           you code should be fewer than 10 characters and should not
166           include special characters or spaces.
167
168 -  'Report is public' should be left to the default of 'No' in most
169    cases. A report can be made public if you intend to allow access to
170    it through the JSON webservice interface. This is a system that can
171    be used by developers to make custom presentations of the data from
172    the report, for example displaying it using a graphing API. To learn
173    more speak to your local developer.
174
175    -  A public report is accessible via a URL that looks like this:
176       http://MYOPAC/cgi-bin/koha/svc/report?id=REPORTID
177
178 -  'Notes' will also appear on the Saved Reports page, this can be used
179    to provide more details about the report or tips on how to enter
180    values when it runs
181
182 -  The type should always be 'Tabular' at this time since the other
183    formats have not been implemented
184
185 -  In the 'SQL' box you will type or paste the SQL for the report
186
187 -  If you feel that your report might be too resource intensive you
188    might want to consider using runtime parameters to your query.
189    Runtime parameters basically make a filter appear before the report
190    is run to save your system resources.
191
192    There is a specific syntax that Koha will understand as 'ask for
193    values when running the report'. The syntax is <<Question to
194    ask\|authorized\_value>>.
195
196    -  The << and >> are just delimiters. You must put << at the
197       beginning and >> at the end of your parameter
198
199    -  The 'Question to ask' will be displayed on the left of the string
200       to enter.
201
202    -  The authorized\_value can be omitted if not applicable. If it
203       contains an authorized value category, or branches or itemtype or
204       categorycode or biblio\_framework, a list with the Koha authorized
205       values will be displayed instead of a free field Note that you can
206       have more than one parameter in a given SQL Note that entering
207       nothing at run time won't probably work as you expect. It will be
208       considered as "value empty" not as "ignore this parameter". For
209       example entering nothing for : "title=<<Enter title>>" will
210       display results with title='' (no title). If you want to have to
211       have something not mandatory, use "title like <<Enter title>>" and
212       enter a % at run time instead of nothing
213
214    Examples:
215
216    -  SELECT surname,firstname FROM borrowers WHERE branchcode=<<Enter
217       patrons library\|branches>> AND surname like <<Enter filter for
218       patron surname (% if none)>>
219
220    -  SELECT \* FROM items WHERE homebranch = <<Pick your
221       branch\|branches>> and barcode like <<Partial barcode value here>>
222
223    -  SELECT title , author FROM biblio WHERE frameworkcode=<<Enter the
224       frameworkcode\|biblio\_framework>>
225
226        **Note**
227
228        To generate a date picker calendar to the right of the field when
229        running a report you can use the 'date' keyword like this:
230        <<Enter Date\|date>>
231
232        Date Picker
233        |image893|
234
235        **Note**
236
237        You have to put "%" in a text box to 'leave it blank'. Otherwise,
238        it literally looks for "" (empty string) as the value for the
239        field.
240
241        **Important**
242
243        In addition to using any authorized value code to generate a
244        dropdown, you can use the following values as well: Framework
245        codes (biblio\_framework), Branches (branches), Item Types
246        (itemtypes) and Patron Categories (categorycode). For example a
247        branch pull down would be generated like this
248        <<Branch\|branches>>
249
250        Branch pull down
251        |image894|
252
253     **Note**
254
255     There is a limit of 10,000 records put on SQL statements entered in
256     Koha. To get around this you want to add 'LIMIT 100000' to the end
257     of your SQL statement (or any other number above 10,000).
258
259     **Note**
260
261     If your system administrator has set up memcache on your server you
262     might see one more option for the Cache expiry. This is related to
263     your public reports. If you make the report public then it's
264     constantly running and will cause a large load on your system.
265     Setting this value prevents that.Cache expiry
266
267 Once everything is entered click the 'Save Report' button and you'll be
268 presented with options to run it. Once a report is saved you do not have
269 to recreate it you can simply find it on the Saved Reports page and
270 `run <#runcustomreport>`__ or `edit <#editcustomreports>`__ it.
271
272 `Duplicate Report <#duplicatereport>`__
273 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
274
275 Reports can also be added by duplicating an existing report. Visit the
276 'Saved reports' page to see all of the reports listed on your system
277 already.
278
279 Saved Reports
280 |image895|
281
282 To the right of every report there is an 'Actions' pull down. Clickin
283 that and choose 'Duplicate' to use an existing report as the basis for
284 your new report. That will populate the new report form with the
285 existing SQL for easy editing and resaving.
286
287 `Edit Custom Reports <#editcustomreports>`__
288 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
289
290 Every report can be edited from the reports lists. To see the list of
291 reports already stored in Koha, click 'Use Saved.'
292
293 Saved Reports
294 |image896|
295
296 To find the report you'd like to edit you can sort by any of the columns
297 by clicking the on the column header. You can also filter your results
298 using the filter menu on the left or use the tabs to find reports based
299 on your custom groups.
300
301 From this list you can edit any custom report by clicking 'Actions' to
302 the right of the report and choosing 'Edit' from the menu that appears.
303
304 Edit Report Option
305 |image897|
306
307 The form to edit the report will appear.
308
309 Edit SQL Form
310 |image898|
311
312 `Running Custom Reports <#runcustomreport>`__
313 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
314
315 Once custom reports are saved to Koha, you can run them by going to the
316 Saved Reports page and clicking the 'Actions' button to the right of the
317 report and choosing 'Run'.
318
319 Run Report
320 |image899|
321
322 When you report runs you will either be asked for some values
323
324 Enter report parameters
325 |image900|
326
327 or you will see the results right away
328
329 Report results
330 |image901|
331
332 From the results you can choose to rerun the report by clicking 'Run
333 report' at the top, edit the report by clicking the 'Edit' button or
334 starting over and creating a new report by using the 'New' button. You
335 can also download your results by choosing a file type at the bottom of
336 the results next to the 'Download the report' label and clicking
337 'Download.'
338
339     **Note**
340
341     A Comma Separated Text file is a CSV file and it can be opened by
342     any spreadsheet application.
343
344 `Statistics Reports <#statsreports>`__
345 --------------------------------------
346
347 Statistic reports will show you counts and sums. These reports are all
348 about numbers and statistics, for reports that return more detailed
349 data, use the `Guided Report Wizard <#quidedreportwizard>`__. These
350 reports are limited in what data they can look at, so it's often
351 recommended to use `custom reports <#customreports>`__ for official end
352 of the year statistics.
353
354 `Acquisitions Statistics <#acqstats>`__
355 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
356
357     **Note**
358
359     These reports are limited in what data they can look at, so it's
360     often recommended to use `custom reports <#customreports>`__ for
361     official end of the year statistics.
362
363 Using the form provided, choose which value you would like to appear in
364 the Column and which will appear in the Row.
365
366 Acquisitions Statistics
367 |image902|
368
369 If you choose to output to the browser your results will print to the
370 screen.
371
372 Acquisitions Statistics Results
373 |image903|
374
375 You can also choose to export to a file that you can manipulate to your
376 needs.
377
378 When generating your report, note that you get to choose between
379 counting or summing the values.
380
381 Acquisitions Stats Options
382 |image904|
383
384 Choosing amount will change your results to appear as the sum of the
385 amounts spent.
386
387 Acquisitions statistics with totals
388 |image905|
389
390 `Patron Statistics <#patstats>`__
391 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
392
393     **Note**
394
395     These reports are limited in what data they can look at, so it's
396     often recommended to use `custom reports <#customreports>`__ for
397     official end of the year statistics.
398
399 Using the form provided, choose which value you would like to appear in
400 the Column and which will appear in the Row.
401
402 Patron Statistics Options
403 |image906|
404
405 If you choose to output to the browser your results will print to the
406 screen.
407
408 Patron Statistics Results
409 |image907|
410
411 Based on your selections, you may see some query information above your
412 results table. You can also choose to export to a file that you can
413 manipulate to your needs.
414
415 `Catalog Statistics <#catstats>`__
416 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
417
418     **Note**
419
420     These reports are limited in what data they can look at, so it's
421     often recommended to use `custom reports <#customreports>`__ for
422     official end of the year statistics.
423
424 Using the form provided, choose which value you would like to appear in
425 the Column and which will appear in the Row.
426
427 Catalog Statistics Form
428 |image908|
429
430 If you choose to output to the browser your results will print to the
431 screen.
432
433 Catalog Statistic Results
434 |image909|
435
436 You can also choose to export to a file that you can manipulate to your
437 needs.
438
439 `Circulation Statistics <#circstats>`__
440 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
441
442     **Note**
443
444     These reports are limited in what data they can look at, so it's
445     often recommended to use `custom reports <#customreports>`__ for
446     official end of the year statistics.
447
448 Using the form provided, choose which value you would like to appear in
449 the Column and which will appear in the Row.
450
451 Circulation Statistics
452 |image910|
453
454 If you choose to output to the browser your results will print to the
455 screen.
456
457 Circulation Statistic Results
458 |image911|
459
460 You can also choose to export to a file that you can manipulate to your
461 needs.
462
463     **Note**
464
465     To get a complete picture of your monthly or daily circulation, you
466     can run the report twice, once for 'Type' of 'Checkout' and again
467     for 'Renewal.'
468
469     This report uses 'Period,' or date, filtering that allows you to
470     limit to a month by simply selecting the first day of the first
471     month through the first day of the next month. For example, 10/1 to
472     11/1 to find statistics for the month of October.
473
474     -  To find daily statistics, set your date range.</br> Example: "I
475        want circulation data starting with date XXX up to, but not
476        including, date XXX."
477
478     -  For a whole month, an example range would be: 11/01/2009 to
479        12/01/2009
480
481     -  For a whole year, an example range would be: 01/01/2009 to
482        01/01/2010
483
484     -  For a single day, an example would be: 11/15/2009 to 11/16/2009
485        to find what circulated on the 15th
486
487 `Tracking in house use <#inhouseuse>`__
488 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
489
490 Using the Circulation statistics reporting wizard you can run reports on
491 in house usage of items simply by choosing 'Local Use' from the 'Type'
492 pull down:
493
494 In House Use Stats
495 |image912|
496
497 `Serials Statistics <#serialstats>`__
498 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
499
500     **Note**
501
502     These reports are limited in what data they can look at, so it's
503     often recommended to use `custom reports <#customreports>`__ for
504     official end of the year statistics.
505
506 Using the form provided, choose how you would like to list the serials
507 in your system.
508
509 Serials Statistics
510 |image913|
511
512 If you choose to output to the browser your results will print to the
513 screen.
514
515 Serials Results
516 |image914|
517
518 You can also choose to export to a file that you can manipulate to your
519 needs.
520
521 `Holds Statistics <#holdstats>`__
522 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
523
524     **Note**
525
526     These reports are limited in what data they can look at, so it's
527     often recommended to use `custom reports <#customreports>`__ for
528     official end of the year statistics.
529
530 Using the form provided you can see statistics for holds placed, filled,
531 cancelled and more at your library. From the form choose what value you
532 want to display in the column and what value to show in the row. You can
533 also choose from the filters on the far right of the form.
534
535 Hold Statistics Form
536 |image915|
537
538 If you choose to output to the browser your results will print to the
539 screen.
540
541 Hold Stats Results
542 |image916|
543
544 You can also choose to export to a file that you can manipulate to your
545 needs.
546
547 `Patrons with the most checkouts <#mostcheckouts>`__
548 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
549
550 This report will simply list the patrons who have the most checkouts.
551
552 Patrons with the most checkouts form
553 |image917|
554
555 If you choose to output to the browser your results will print to the
556 screen.
557
558 Top checkouts results
559 |image918|
560
561 You can also choose to export to a file that you can manipulate to your
562 needs.
563
564 `Most Circulated Items <#mostcirculated>`__
565 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
566
567 This report will simply list the items that have the been checked out
568 the most.
569
570 Most Circulation Items Form
571 |image919|
572
573 If you choose to output to the browser your results will print to the
574 screen.
575
576 Top Circulation Items Results
577 |image920|
578
579 You can also choose to export to a file that you can manipulate to your
580 needs.
581
582 `Patrons with no checkouts <#patnocheckouts>`__
583 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
584
585 This report will list for you the patrons in your system who haven't
586 checked any items out.
587
588 Patrons with no Checkouts
589 |image921|
590
591 If you choose to output to the browser your results will print to the
592 screen.
593
594 Results for Patrons with no Checkouts
595 |image922|
596
597 You can also choose to export to a file that you can manipulate to your
598 needs.
599
600 `Items with no checkouts <#itemnocheckouts>`__
601 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
602
603 This report will list items in your collection that have never been
604 checked out.
605
606 Items with No Checkouts
607 |image923|
608
609 If you choose to output to the browser your results will print to the
610 screen.
611
612 Items with no checkouts results
613 |image924|
614
615 You can also choose to export to a file that you can manipulate to your
616 needs.
617
618 `Catalog by Item Type <#catbyitem>`__
619 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
620
621 This report will list the total number of items of each item type per
622 branch.
623
624 Catalog by Item Type
625 |image925|
626
627 If you choose to output to the browser your results will print to the
628 screen.
629
630 Total of Items by Type and Branch
631 |image926|
632
633 You can also choose to export to a file that you can manipulate to your
634 needs.
635
636 `Lost Items <#lostreport>`__
637 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
638
639 This report will allow you to generate a list of items that have been
640 marked as Lost within the system
641
642 Lost Items Report
643 |image927|
644
645 `Average Loan Time <#avloantime>`__
646 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
647
648 This report will list the average time items are out on loan based on
649 the criteria you enter:
650
651 Average Checkout Period Form
652 |image928|
653
654 If you choose to output to the browser your results will print to the
655 screen.
656
657 Average Checkout Period Results
658 |image929|
659
660 You can also choose to export to a file that you can manipulate to your
661 needs.
662
663 `Report Dictionary <#reportdic>`__
664 ----------------------------------
665
666 The report dictionary is a way to pre-define common filters you'd like
667 to apply to your reports. This is a good way to add in filters that the
668 report wizard doesn't include by default. To add a new definition, or
669 filter, click 'New Definition' on the Reports Dictionary page and follow
670 the 4 step process.
671
672 Step 1: Name the definition and provide a description if necessary
673
674 Create a Definition
675 |image930|
676
677 Step 2: Choose the module that the will be queried.
678
679 Select Koha Module
680 |image931|
681
682 Step 3: Choose columns to query from the tables presented.
683
684 Choose columns
685 |image932|
686
687 Step 4: Choose the value(s) from the field(s). These will be
688 automatically populated with options available in your database.
689
690 Choose fields and values
691 |image933|
692
693 Confirm your selections to save the definition.
694
695 Confirm Definition
696 |image934|
697
698 Your definitions will all appear on the Reports Dictionary page
699
700 Reports Dictionary Listing
701 |image935|
702
703 Then when generating reports on the module you created the value for you
704 will see an option to limit by the definition at the bottom of the usual
705 filters.
706
707 Dictionary Limit Option
708 |image936|