I finally found the answer in the docs where it describes the meaning of "Department" value of Settings -> Line Numbers:
Department.
This field allows you to select which department owns the CO line. This information is used to build Daily
Report by Department and Monthly Report by Department from Statistic section on Reports/List page. In these
reports calls are grouped by department basing not on user extension reported by a PBX, but on CO line
information and relations between lines and departments defined in this table.
So, when you do a Statistics->Report by Department, the Department value is derived from the "Line Numbers" (CO) table.
This is in contrast to when you do a "Department Report", where the Department value is instead derived from the "Department/Users" (Extensions) table.
Because of the almost identical names, that difference wasn't easy to spot right away.