Forum Discussion

einrikr's avatar
einrikr
Frequent Visitor
5 years ago
Solved

Determine contract end date based on value from different row

Hi all,   I have a data set like below:  Reporting Date Employee number Name Pool Start date End date 1-1-2021 1 Peter  Sales 01-01-2003   1-2-2021 1 Peter Sales 01-01-2003 ...
  • v-easonf-msft's avatar
    5 years ago

    Hi,  einrikr 

    Try a calculated column like the following:

    End Date = 
    VAR maxdate =
        CALCULATE (
            MAX ( 'Table'[Start date] ),
            FILTER (
                'Table',
                'Table'[Employee number] = EARLIER ( 'Table'[Employee number] )
            )
        )  // Select the largest date after grouping by 'Employee number'
    RETURN
        IF ( 'Table'[Start date] = maxdate, BLANK (), maxdate - 1 )

    Best Regards,
    Community Support Team _ Eason
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Ashish_Mathur's avatar
    5 years ago

    Hi,

    This calculated column formula works

    =if(CALCULATE(countrows(Data),FILTER(Data,Data[Employee number]=EARLIER(Data[Employee number])&&Data[Start date]>EARLIER(Data[Start date])))=0,BLANK(),CALCULATE(MIN(Data[Start date])-1,FILTER(Data,Data[Employee number]=EARLIER(Data[Employee number])&&Data[Start date]>EARLIER(Data[Start date]))))

    Hope this helps.