Forum Discussion

rush's avatar
rush
Helper V
4 years ago
Solved

Practice Changes based on Dates

Hi All   I have a table that records a staff's division data. I am trying to create a table out of it with start and end dates along with identifying when a staff has changed their practice e.g DAT...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi rush ,

    Please refer to my pbix file to see if it helps you.

    yea_no =
    VAR SHANG =
        CALCULATE (
            MAX ( 'Table'[Practice] ),
            FILTER (
                'Table',
                'Table'[EEID] = EARLIER ( 'Table'[EEID] )
                    && 'Table'[Full Name] = EARLIER ( 'Table'[Full Name] )
                    && 'Table'[Index]
                        = EARLIER ( 'Table'[Index] ) - 1
            )
        )
    VAR _xia =
        CALCULATE (
            MAX ( 'Table'[Practice] ),
            FILTER (
                'Table',
                'Table'[EEID] = EARLIER ( 'Table'[EEID] )
                    && 'Table'[Full Name] = EARLIER ( 'Table'[Full Name] )
                    && 'Table'[Index]
                        = EARLIER ( 'Table'[Index] ) + 1
            )
        )
    VAR _result =
        IF ( ISBLANK ( SHANG ), _xia, SHANG )
    RETURN
        IF ( _result <> 'Table'[Practice], "Yes", "No" )
    
    start_ = 'Table'[Job Information - Effective Date]
    end_ =
    VAR _mindate =
        CALCULATE (
            MAX ( 'Table'[Job Information - Effective Date] ) - 1,
            FILTER (
                ALL ( 'Table' ),
                'Table'[Full Name] = EARLIER ( 'Table'[Full Name] )
                    && 'Table'[EEID] = EARLIER ( 'Table'[EEID] )
                    && 'Table'[yea_no] = "Yes"
            )
        )
    VAR insertmin =
        CALCULATE (
            MIN ( 'Table'[Job Information - Effective Date] ),
            FILTER (
                ALL ( 'Table' ),
                'Table'[Full Name] = EARLIER ( 'Table'[Full Name] )
                    && 'Table'[EEID] = EARLIER ( 'Table'[EEID] )
                    && 'Table'[yea_no] = "Yes"
            )
        )
    RETURN
        IF (
            'Table'[Job Information - Effective Date] = insertmin
                && 'Table'[Termination Date] = BLANK (),
            _mindate,
            IF (
                'Table'[Job Information - Effective Date] <> insertmin
                    && 'Table'[Termination Date] = BLANK (),
                TODAY (),
                IF (
                    'Table'[Job Information - Effective Date] = insertmin
                        && 'Table'[Termination Date] <> BLANK (),
                    _mindate,
                    IF (
                        'Table'[Job Information - Effective Date] <> insertmin
                            && 'Table'[Termination Date] <> BLANK (),
                        'Table'[Termination Date],
                        BLANK ()
                    )
                )
            )
        )
    

     

     

    Best Regards

    Community Support Team _ Polly

     

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