Hmmm… this is a tricky one, because Airtable unfortunately doesn’t give us programmatic access to those summary numbers that appear on the screen. This is one of my top feature requests for Airtable! I would recommend that you email them as well at email@example.com to request this as a feature.
For my clients, I use Integromat’s Numeric Aggregator to loop through the records, group them by the group that I want, and then return the summary value for each group. But this is also quite the challenge to setup in Integromat as well — it takes several hours to fully craft this scenario in Integromat. (If you need help with setting this up in Integromat, I’m a Registered Integromat Partner and you can reach out to me via my website at scottworld.com).