I'm trying to find the correct expression to return DISTINCT counts of customers by Fiscal Year. Blank end dates means that they are current customers. Customers can be in multiple programs at one time, but should still only be counted as a single distinct customer. Here is an example of the dataset:
CustomerID | ProgramID | StartDate | EndDate | Fiscal Year Start | Fiscal Year End |
111 | 1 | 1/1/2013 | 2013 | ||
222 | 1 | 1/1/2014 | 7/1/2014 | 2014 | 2015 |
333 | 1 | 1/1/2016 | 2016 | ||
444 | 1 | 6/1/2014 | 12/31/2015 | 2014 | 2015 |
333 | 2 | 2/1/2016 | 5/1/2016 | 2016 | 2016 |
Here is the output that is needed:
Fiscal Year | # of Customers |
2013 | 1 |
2014 | 3 |
2015 | 3 |
2016 | 2 |