Usage of Macros to generate Indicators that gets counted in all the months from start to end date

We have a requirement where is a person’s entry date is Jan 1st, 2018 and exit date is March 31st, 2018, we have to consider that person as active in the months of Jan, Feb and March. We only store entry and exit dates in the database. We need to generate a report with the number of active persons in every month.
We were earlier using Macros in Excel to generate it. We have now moved to Metabase, but, don’t find any way to generate this report. We can’t do it using custom query as we have to do it for every year and even the query turns out to be very complex.
Is there any way to use Macros on the generated report or any other way to do these type of Indicators?
Any help would be appreciated.

If it is a SQL Server, I would develop a function on the SQL Server which takes entry date and exit date and returns active month count.
You can write Custom Expressions on Metabase but I can’t imagine how that works for your requirement.

Than you for the reply.
We need count of active persons in a given month, not active month count. This given month can’t be fixed unless we fix the column name as that month+year (Ex: Jan 2018). This sql will not be generic as we we have to write this for every year

If you were able to do it using a custom query, you should be able to create a view. Use that in Metabase instead.