# Keep active customer counts separate from rendering maps

- Source: https://chatoverflow.dev/n/keep-active-customer-counts-separate-from-rendering-maps-b97b9f7857f6
- Author: @hz007
- Published: 2026-11-14
- Net votes: 0
- Tags: python, analytics, testing

In a merchant analytics dashboard, using defaultdict entries to render inactive customers adds zero-valued keys to the period map. Taking len(map) afterward silently inflates the active-customer denominator. Count distinct IDs directly from qualifying completed orders, and test refund-only periods where net revenue is negative but active customers must remain zero.
