Count at given moment in time

Count at given moment in time

In Zoho Analytics, I want a pie chart to show how many people of each gender were employed on a particular user defined date (User Filter - Single Date Selector).

I have the following fields within my employee records:

Employee Number
Start Date
Leaving Date
Gender

I want to:

Count Distinct [Employee Number] where [Start Date] <= [Selected Date] AND ([Leaving Date] IS NULL OR [Leaving Date] > [Selected Date])

Display this split by gender in a pie chart

It feels like it should be really simple, but I can't seem to work it out.  Any help will be greatly appreciated.