Forum Discussion

heatherkw's avatar
heatherkw
Icon for Helper I rankHelper I
3 years ago
Solved

Find Next Enrollment for Client Based on Certain Conditions

Hello, I am still pretty new to DAX and I have looked around for solutions, but they are not quite the same as my scenario, or I'm just not well-versed enough in DAX to understand how to make it work...
  • v-yanjiang-msft's avatar
    v-yanjiang-msft
    3 years ago

    Hi heatherkw ,

    According to your description, I enriched my sample.

    I create four scenarios.

    1.The next Enrollment is the same PersonalID and ProgramType is Emergency Shelter and within 12 months.

    2.The next Enrollment is the same PersonalID and ProgramType isn't Emergency Shelter or Transitional Housing and within 12 months.

    3.The next Enrollment isn't the same PersonalID and ProgramType is Emergency Shelter and within 12 months.

    4.The next Enrollment is the same PersonalID and ProgramType is Transitional Housing and within 12 months.

     

    I modify the formula:

    Column =
    IF (
        [ExitType] = "Permanent",
        IF (
            MAXX (
                FILTER (
                    'Table',
                    'Table'[EnrollmentID]
                        = EARLIER ( 'Table'[EnrollmentID] ) + 1
                ),
                'Table'[ProgramType]
            )
                IN { "Emergency Shelter", "Transitional Housing" }
                    && DATEDIFF (
                        'Table'[ExitDate],
                        MAXX (
                            FILTER (
                                'Table',
                                'Table'[EnrollmentID]
                                    = EARLIER ( 'Table'[EnrollmentID] ) + 1
                            ),
                            'Table'[Enrollment Date]
                        ),
                        MONTH
                    ) <= 12
                    && 'Table'[PersonalID]
                        = MAXX (
                            FILTER (
                                'Table',
                                'Table'[EnrollmentID]
                                    = EARLIER ( 'Table'[EnrollmentID] ) + 1
                            ),
                            'Table'[PersonalID]
                        ),
            1,
            0
        )
    )
    

    Get the result.

    I attach my sample below for your reference.

     

    Best Regards,
    Community Support Team _ kalyj

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.