i've copied 'library reports' command description from the wiki. alr (and alr virtual tag functions) has exactly the same functionality, only ui is slightly different, but these instructions and examples are totally applicable to alr.
edit:
i've slightly adopted instructions for alr. will adopt them more later.
------------------------------------------------------------------------
ALR virtual tag functions allow to gather and display in the main panel some library statistics for currently displayed tracks.
NOTE 1:
Main ALR window supports for two types of fields: grouping tags and aggregated functions. Every aggregated function is calculated for every unique combination of grouping tags. 'Count' function counts the number of different values of a given (function parameter, not grouping) tag. Other functions are obvious and should be applied only to numeric or duration (parameter) tags (e.g. 'Time', 'File size', etc.).
NOTE 2:
All ALR virtual tag function are calculated, updated and displayed dynamically.
NOTE 3:
For all aggregated functions except for 'Count' function please make sure that all (parameter) tag values used by function have the same measurement units (KB, MB, etc.) or adjust units in 'Edit/Preferences/Plugins' window (not required if both MusicBee and Windows localizations are English or Russian).
EXAMPLE 1
If you want to get the number of albums of artist of displayed track, i.e. the number of albums (function 'Count' of (parameter) tag 'Album') per artist (tag 'Album Artist'), you should add grouping tag 'Album Artist' in the table and required function 'Count(Album)'. Assign some_function_id to this aggregated function. Create virtual tag with formula $ALR(<URL>,some_function_id). Add this virtual tag to the main panel.
EXAMPLE 2
If you want to get the number of releases of artist (of displayed track) per year (of displayed track), i.e. the number of albums (function 'Count' of (parameter) tag 'Album') per year (tag 'Year') per artist (tag 'Album Artist'), you should add grouping tags (in order) 'Album Artist' and 'Year' in the table and required function 'Count(Album)'. Assign some_function_id to this aggregated function. Create virtual tag with formula $ALR(<URL>,some_function_id). Add this virtual tag to the main panel.
EXAMPLE 3
If you want to get the total duration of all tracks of artist of displayed track, i.e. the sum of track durations (function 'Sum' of tag 'Time') per artist (tag 'Album Artist'), you should add grouping tag 'Album Artist' and function 'Sum(Time)'. Assign some_function_id to this aggregated function. Create virtual tag with formula $ALR(<URL>,some_function_id). Add this virtual tag to the main panel.
See two predefined presets 'LIBRARY TOTALS' and 'LIBRARY AVERAGES' of (not auto) 'Library Reports' command for more examples.
ALR virtual tag functions are even more useful if they are used in grouping header in 'Albums and Track' view: