Custom Expression - % of market share

I'm trying to keep my question a Non SQL question so that I can use dashboard filters.

I want a custom expression that counts the distinct number of customer codes from the sales lines table and divide that my the count of customer codes from the customer table. I have a date filter on the question, so basically this is trying to show the % of customers who bought from us in a specific time period from the number of all our customers.

I can't for my life get a custom expression to work for this... please help