Sixth Report Challenge: A client wants to add a custom label to on of the headings in the report results

Sixth Report Challenge: A client wants to add a custom label to on of the headings in the report results


These notes are intended to be used to help answer the associated Report Challenge that was released this week.

Take a look at the question below and think about how you would approach answering it:



Info
A client wants to add a custom label to on of the headings in the report results 




Idea
Key points in this challenge:
There are options for customising the appearance of report results
Field labels in report results will always follow the format in the Koha database schema


We can apply new labels to the headings of any report, including the reports created for the previous report challenges. Try to start by looking at an existing report to work on adding a new label to it or click the dropdown below to view the content of a report you can work with.
Content of report to add a new label to
SELECT borrowers.cardnumber, borrowers.firstname, borrowers.surname
FROM borrowers
LIMIT 50

Default view of report results

When you run the report without alias created, the results will appear in a table with the default field names in the database at the top row of the table. 

These labels  are drawn from the Koha database schema so they are accurate, but can sometimes be hard to read. Or, a client may want to download the report results and use  them for something within the library, so it might be useful to have headings that relate to the work, once the data is out of the context of Koha specifically. For example, if there was a list of volunteers or there were items to be moved to a specific location, a client might want the headings for those columns to reflect that function. 

Adding a custom label in the report results

A new label for report results  is called an alias. We will outline the format for adding an alias using a specific example, but the basic format can be applied across any report.

Notes
For more details on alias, please click here.

To add an alias to a report, identify the field in the report results to add an alias for.



To add a label to the result field insert the command AS. 



Type in the preferred label for the field in quotes. 



Running this report will show results using the defined alias instead of the standard label from the table in the database.