You will have to build a Statistics Collector or other logic to collect that data.
You can use querySlots() to get the number of used slots. Though in order to measure the average number of used slots you will have to do this every time an item enters or exits a slot. Depending on the number of slots, this can become quite expensive in terms of computing resources, so I would suggest to instead store the value of currently used slots somewhere (a label or as part of the Statistics Collector table) and simply increment/decrement it whenever the first item enters a slot or the last item leaves a slot.
For the average, you can add up the time for which slots had at least one item in them, summed up over all slots inside a rack. So you essentially get a "SlotSeconds" value (X slots were active for Y seconds -> XY SlotSeconds. By dividing this by the total model time, you get the average number of occupied slots. Again, this can be done by storing the previous value and adding to it whenever the number of currently used slots updates. Or by using a kinetic tracked variable (for example as a label), whose rate is always equal to the current number of active slots.
Both approaches (StatisticsCollector and Labels on Rack1) are demonstrated in the attached model. The collector listens to slot entries/exits in the "Racks" group. The labels of Rack1 are updated in its triggers.
SlotStats.fsm