Forum Discussion
AbhinavJoshi
Responsive Resident
2 years agoCalculate Year over Year Count
Hello, I have the following dataset Clients Table ClientID, MonthsActive, YearsActive, IsTerminated, TotalLives, SizeBand, TerminationDate, EnrollmentDate. If the client is still active the Is...
- 2 years ago
Hi AbhinavJoshi ,
Create a separate dates table:
Dates = ADDCOLUMNS ( CALENDAR ( DATE ( 2007, 1, 1 ), TODAY () ), "Year", YEAR ( [Date] ), "YYYYMM", FORMAT ( [Date], "YYYYMM" ) )Link this to Enrollment date (active relationship) and Termination Date (inactive) usingi a one to many single direction relationship.
Create these measures:
Enrolled = CALCULATE ( COUNTROWS ( 'Table' ), FILTER ( ALL ( Dates ), Dates[Date] <= MAX ( Dates[Date] ) ) ) Terminated = CALCULATE ( COUNTROWS ( 'Table' ), FILTER ( ALL ( Dates ), Dates[Date] <= MAX ( Dates[Date] ) && NOT ( ISBLANK ( Dates[Date] ) ) ), USERELATIONSHIP ( Dates[Date], 'Table'[TerminationDate] ) ) Active = [Enrolled] - [Terminated]Or you can put them in one measure instead. I separate them so you can see what happens for each.
I modified your sample data a bit by adding an extra termination date for Account2. Please refer to the attached pbix for the details.
danextian
Super User
2 years agoHi AbhinavJoshi
As always, please post a sample data and your expected result from that. Sample data should be workable (not a screenshot) and a representation of your actual data (not overly simplified). Please refer to this stick post: