```ts
function countBy(records: Record<string, string>[], field: string): Record<string, number> {
  if (field.trim() === "") throw new Error("Field name cannot be empty text");

  const counts = {};
  for (const record of records) {
    const value = record[field];
    if (!value) continue; // Skip records without the specified field
    counts[value] = (counts[value] || 0) + 1;
  }

  return counts;
}
```