Forum Discussion
Count active dossiers per month
Hi,
Hope somebody can help me! I have data with dossiers that have a startdate, but no enddate and dossiers that have a start and end date. This is the data:
| Dossiernumber | Startdate | Enddate |
| 1 | 04-02-2008 | |
| 2 | 10-05-2010 | |
| 3 | 22-11-2018 | 18-04-2022 |
| 4 | 31-05-2021 | 31-12-2021 |
I would like an output that counts the number of dossiers that were active in a month. For example, the startdate is 01 jan 2022 and the enddate is 31 mar 2022 I would like the table to present a follows:
| Jan | Feb | Mar | Apr |
| 1 | 1 | 1 | 0 |
I have Calander table that is linked to the data.
I have a Measure that shows the cumulative number of dossiers:
I searched a lot and tried a lot of things that I found, but it does not give me the outcome that I am looking for.
Try this solution. It uses a secondary date table DimDateVisual that has no relationship to the fact table.
Create measure:
Active Dossiers = VAR vMinDate = MIN ( DimDateVisual[Date] ) VAR vMaxDate = MAX ( DimDateVisual[Date] ) VAR vTable = FILTER ( FactTable, VAR vEndDate = IF ( ISBLANK ( FactTable[Enddate] ), DATE ( 9999, 12, 31 ), FactTable[Enddate] ) RETURN FactTable[Startdate] <= vMaxDate && vEndDate >= vMinDate ) VAR vResult = CALCULATE ( COUNT ( FactTable[Dossiernumber] ), vTable ) RETURN vResultData:
The matrix columns should use DimDateVisual[Month Year]:
2 Replies
- DataInsights
Super User
Try this solution. It uses a secondary date table DimDateVisual that has no relationship to the fact table.
Create measure:
Active Dossiers = VAR vMinDate = MIN ( DimDateVisual[Date] ) VAR vMaxDate = MAX ( DimDateVisual[Date] ) VAR vTable = FILTER ( FactTable, VAR vEndDate = IF ( ISBLANK ( FactTable[Enddate] ), DATE ( 9999, 12, 31 ), FactTable[Enddate] ) RETURN FactTable[Startdate] <= vMaxDate && vEndDate >= vMinDate ) VAR vResult = CALCULATE ( COUNT ( FactTable[Dossiernumber] ), vTable ) RETURN vResultData:
The matrix columns should use DimDateVisual[Month Year]:
- CarlijnMFrequent Visitor
Tank you very much!